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

Custom expression: new function ISNULL() and ISEMPTY() #14866

Merged
merged 1 commit into from
Feb 20, 2021

Conversation

ariya
Copy link
Contributor

@ariya ariya commented Feb 17, 2021

These new functions are to support MBQL's is-null and is-empty. This is to address issue #12225.

Steps to verify

  1. Ask a question, Custom question
  2. Sample Dataset, Reviews table
  3. Filter, Add filters to narrow your answer, Custom Expression
  4. Type NOT isempty([Reviewer] ), click Done
  5. Click on the + button, another Custom Expression
  6. Type NOT isnull([Rating]), click Done
  7. Visualize

Before this PR

It was not possible, since custom expression's IsNull and IsEmpty functions did not exist.

After this PR

image

Additional Note

The simple filter "Is empty" can be also (properly) converted to a custom expression:

  1. Ask a question, Simple question, Reviews
  2. Filter, Reviewer, Is empty and then click Add filter
  3. Click on the new "Reviewer is empty" filter
  4. Click on the left chevron icon, Custom Expression

image

The same also works for Discount:

image

Note that is-null vs is-empty depends on the field type, see PR #12947 for more details.

Related issue: negative filter doesn't get converted yet, see #14880 for more details.

@ariya ariya marked this pull request as draft February 17, 2021 22:35
@ariya ariya force-pushed the custom-expression/null-empty branch from 5a403e7 to 5c7d055 Compare February 17, 2021 22:38
@flamber
Copy link
Contributor

flamber commented Feb 18, 2021

For historians, might wanna look in #5299 - I think it's great to have specific functions in CE, whereas the regular filter options is fine having "Is empty", which is (column IS NULL OR column = '')

@ariya ariya force-pushed the 0.39-improve-custom-expression branch from f7075f1 to 1d373a6 Compare February 19, 2021 03:19
These new functions are to support MBQL's is-null and is-empty.
@ariya ariya force-pushed the custom-expression/null-empty branch from 5c7d055 to 8f47490 Compare February 19, 2021 03:23
@ariya ariya changed the title Custom expression: support for is-null and is-empty Custom expression: new function ISNULL() and ISEMPTY() Feb 19, 2021
@ariya ariya marked this pull request as ready for review February 19, 2021 03:44
Copy link
Contributor

@flamber flamber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great! 🎉 And the code is just like the other functions, now the backend is in place.
I can even do case(isnull([Field]), "NULL", NOT isnull([Field]), "NOT NULL") for a CC

@ariya ariya merged this pull request into 0.39-improve-custom-expression Feb 20, 2021
@ariya ariya deleted the custom-expression/null-empty branch February 20, 2021 00:28
@ariya ariya mentioned this pull request Feb 20, 2021
18 tasks
ariya added a commit that referenced this pull request Feb 21, 2021
These new functions are to support MBQL's is-null and is-empty.
ariya added a commit that referenced this pull request Feb 25, 2021
These new functions are to support MBQL's is-null and is-empty.
ariya added a commit that referenced this pull request Feb 26, 2021
These new functions are to support MBQL's is-null and is-empty.
ariya added a commit that referenced this pull request Mar 1, 2021
These new functions are to support MBQL's is-null and is-empty.
ariya added a commit that referenced this pull request Mar 1, 2021
These new functions are to support MBQL's is-null and is-empty.
ariya added a commit that referenced this pull request Mar 2, 2021
These new functions are to support MBQL's is-null and is-empty.
ariya added a commit that referenced this pull request Mar 2, 2021
These new functions are to support MBQL's is-null and is-empty.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants