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

Add python filters is_null, is_not_null, and Filter.not_() #3736

Merged
merged 2 commits into from
Apr 26, 2023

Conversation

devinrsmith
Copy link
Member

No description provided.

Comment on lines 108 to 116
def is_null(col: str) -> Filter:
"""Creates a new filter that evaluates to true when the col is null, and evaluates to false when col is not null.

Args:
col (str): the column name

Returns:
a new is-null Filter
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

Would Filter.from_("X == null") be equivalent to 'is_null("X")?

Copy link
Member Author

@devinrsmith devinrsmith Apr 25, 2023

Choose a reason for hiding this comment

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

It's logically the same, and will produce the same looking results, but the engine will do different things.

Filter.from_("X == null") will cause java to compile a filter kernel (ConditionFilter), whereas is_null("X") is able to construct a much more efficient MatchFilter.

Copy link
Member Author

Choose a reason for hiding this comment

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

The more idiomatic way to express this via string would be from_("isNull(X)"), but that still results in ConditionFilter.

Copy link
Contributor

@jmao-denver jmao-denver Apr 25, 2023

Choose a reason for hiding this comment

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

Currently we give the users two ways to specify filter conditions: the string condition expressions and the Filter objects. Since Filters are much more efficient, it makes sense to provide ways to construct Filters that represent all sorts of conditions. We could also improve the filter parser to automatically translate a string condition expression (which is more intuitive to read) into a Filter object. @chipkent your thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

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

"MatchFilter" is not a regex construction, it's a "match from this list of values" construction.

Copy link
Member

Choose a reason for hiding this comment

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

We could and should be doing more smart things in how we interpret string filters. As long as we have the option to do the optimization in the future, we haven't painted ourselves into a corner, which is good.

py/server/deephaven/filters.py Show resolved Hide resolved
@devinrsmith devinrsmith changed the title Add python filters is_null and Filter.not_() Add python filters is_null, is_not_null, and Filter.not_() Apr 26, 2023
Copy link
Contributor

@jmao-denver jmao-denver left a comment

Choose a reason for hiding this comment

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

LGTM

@devinrsmith devinrsmith dismissed chipkent’s stale review April 26, 2023 18:16

It was account for.

@devinrsmith devinrsmith enabled auto-merge (squash) April 26, 2023 18:17
@devinrsmith devinrsmith merged commit be21ea5 into deephaven:main Apr 26, 2023
@devinrsmith devinrsmith deleted the filters-is-null branch April 26, 2023 18:20
@github-actions github-actions bot locked and limited conversation to collaborators Apr 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants