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

[Enhancement] in null/not having null supports normalized to value range #54646

Merged
merged 5 commits into from
Jan 6, 2025

Conversation

trueeyu
Copy link
Contributor

@trueeyu trueeyu commented Jan 3, 2025

Why I'm doing:

Currently, only the following pred can be normalized:

  • ColumnRef is null
  • ColumnRef is no null
  • ColumnRef >, >=, <, <=, = const value
  • ColumnRef in const values
  • ColumnRef not in const values
  • The above are combined by or, and

The [ColumnRef in (xxx, yyy, zzz)] is null is not support to be normalized, so the null in in pred or not in pred can be eliminated.

in (xxx, yyy, zzz, null) can be converted to in (xxx, yyy, zzz)
not in (xxx, yyy, zzz, null) can be converted to not in (null), and then convert to empty range.

Finally the in pred with null can be used to filter with zonemap or other index.

Before the pr:

mysql> select count(*) from lineorder_nullable_1_tablet_large where lo_orderkey in (1, 2, null);
+----------+
| count(*) |
+----------+
|        4 |
+----------+
1 row in set (0.64 sec)

mysql> select count(*) from lineorder_nullable_1_tablet_large where lo_orderkey not in (1, 2, null);
+----------+
| count(*) |
+----------+
|        0 |
+----------+
1 row in set (0.59 sec)

After the pr

mysql> select count(*) from lineorder_nullable_1_tablet_large where lo_orderkey in (1, 2, null);
+----------+
| count(*) |
+----------+
|        4 |
+----------+
1 row in set (0.06 sec)

mysql> select count(*) from lineorder_nullable_1_tablet_large where lo_orderkey not in (1, 2, null);
+----------+
| count(*) |
+----------+
|        0 |
+----------+
1 row in set (0.02 sec)

What I'm doing:

in null/not in null supports normalized to value range

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.4
    • 3.3
    • 3.2
    • 3.1
    • 3.0

@mergify mergify bot assigned trueeyu Jan 3, 2025
@trueeyu trueeyu changed the title [WIP] in null/not in null supports normalized to value range [Enhancement] in null/not in null supports normalized to value range Jan 3, 2025
@trueeyu trueeyu changed the title [Enhancement] in null/not in null supports normalized to value range [Enhancement] in null/not having null supports normalized to value range Jan 3, 2025
Signed-off-by: trueeyu <[email protected]>
@trueeyu trueeyu marked this pull request as ready for review January 3, 2025 07:41
@trueeyu trueeyu requested review from a team as code owners January 3, 2025 07:41
Signed-off-by: trueeyu <[email protected]>
Signed-off-by: trueeyu <[email protected]>
Signed-off-by: trueeyu <[email protected]>
Copy link

github-actions bot commented Jan 6, 2025

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

github-actions bot commented Jan 6, 2025

[FE Incremental Coverage Report]

pass : 0 / 0 (0%)

@@ -130,6 +130,7 @@ class ColumnValueRange {
TCondition to_olap_not_null_filter() const;

void clear();
void clear_to_empty();
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the difference between clear() and clear_to_empty()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

clear_to_empty means all values is filtered,EOF. but clear means to init state, is full range.

Copy link

github-actions bot commented Jan 6, 2025

[BE Incremental Coverage Report]

fail : 29 / 39 (74.36%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 be/src/exec/olap_scan_prepare.cpp 15 25 60.00% [396, 479, 483, 484, 485, 488, 489, 511, 512, 802]
🔵 be/src/exec/olap_common.cpp 9 9 100.00% []
🔵 be/src/exprs/in_const_predicate.hpp 1 1 100.00% []
🔵 be/src/testutil/schema_test_helper.cpp 4 4 100.00% []

@andyziye andyziye merged commit 52221a3 into StarRocks:main Jan 6, 2025
55 of 56 checks passed
maggie-zhu pushed a commit to maggie-zhu/starrocks that referenced this pull request Jan 7, 2025
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.

4 participants