-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Push down filter as table partition list prefix #10693
Conversation
7278824
to
b47e1e9
Compare
b47e1e9
to
679ab29
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very nice to me -- thanks @houqp . I have two other test suggestions but I don't think they are required
&[Expr::and( | ||
Expr::eq(col("a"), lit("foo")), | ||
Expr::eq(col("b"), lit("bar")), | ||
)], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can write this kind of expression more simply like col("a").eq(lit("foo")).and(col("b").eq(lit("bar")))
though maybe what you have is more readable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the eq helper improves readability, i applied that to all tests. i do agree with you that the .and
helper makes the expression less readable.
// no prefix when filter is empty | ||
assert_eq!(evaluate_partition_prefix(partitions, &[]), None); | ||
|
||
// b=foo results in no prefix because a is not restricted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend adding some other tests:
- another negative test like
a < 5
to cover the fact that only=
predicates are allowed - A test with the literal and constant swapped (
foo = a
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, good suggestions.
679ab29
to
1a29bb5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Rationale for this change
When applicable, table partition listing can be optimized by deriving a listing prefix based on literals provided in the filter predicates.
For a selected table with many partitions, this change reduces query time from minutes to 200ms.
What changes are included in this PR?
stacked on top of Display date32/64 in YYYY-MM-DD format #10691. please review that PR first.evaluate_partition_prefix
function to derive a listing prefix based on filter predicates and table partitions.list_partitions
extended to take an optional prefix argument.Are these changes tested?
Tested with unit tests.
Are there any user-facing changes?
No