Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE]: Add filter to rule #140

Open
1 task done
pierre-monnet opened this issue Jan 28, 2025 · 1 comment · May be fixed by #141
Open
1 task done

[FEATURE]: Add filter to rule #140

pierre-monnet opened this issue Jan 28, 2025 · 1 comment · May be fixed by #141
Labels
enhancement New feature or request

Comments

@pierre-monnet
Copy link

pierre-monnet commented Jan 28, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Problem statement

Problem

I need to apply rules to a part of a DataFrame.

Context

We have a table of tracking events, and depending on the type of event, we want to apply a rule or not.

Example

+---+------------+-----------+---------+--------+
| id|  event_type|button_name|page_from|page_url|
+---+------------+-----------+---------+--------+
|  1|   page_view|       NULL|     NULL|   /home|
|  2|button_click|      login|    /home|    NULL|
|  3|   page_view|       NULL|     NULL|  /login|
|  4|button_click|    sign_in|   /login|    NULL|
+---+------------+-----------+---------+--------+
In this case
  • if the event_type is "page_view", then page_url must be non-null
  • if the event_type is "button_click", then button_name and page_from must be non-null.

Purpose

For this simple example, a sql_expression with both conditions could solve the problem, but for readability, I find it more elegant to keep native rules (here is_not_null) to which we apply a filter. This is even more the case when we want to apply a rule to a list of columns, it's much more readable to do that.

Proposed Solution

- criticality: "error"
  filter: "event_type='page_view'"
  check:
    function: "is_not_null"
    arguments:
      col_name: "page_url"
- criticality: "error"
  filter: "event_type='button_click'"
  check:
    function: "is_not_null"
    arguments:
      col_names: 
        - "button_name"
        - "page_from"

Additional Context

I started a draft PR (#141) with a simple working purpose but there are still a lot of things to validate, for example, how to display filter in _error or _warning result.

@pierre-monnet pierre-monnet added the enhancement New feature or request label Jan 28, 2025
@pierre-monnet pierre-monnet linked a pull request Jan 28, 2025 that will close this issue
3 tasks
@pierre-monnet pierre-monnet changed the title [FEATURE]: Add fitler to rule [FEATURE]: Add filter to rule Jan 28, 2025
@mwojtyczka
Copy link
Contributor

mwojtyczka commented Jan 29, 2025

This is a useful feature. Yes it would be good to include the filter as well in the reporting columns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants