-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: PushDownFilter
for GROUP BY
on uppercase col names
#16049
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
base: main
Are you sure you want to change the base?
Conversation
PushDownFilter
for GROUP BY
on uppercase col names
0495f24
to
14ceef8
Compare
@adriangb Saw you recent commits in this area, would appreciate if you weighed in on this. Thank you! 🙌 |
Hmm I've been doing a lot with the physical optimizer of the same name but haven't touched the logical optimizer. The recent changes may mean that the pushdown ends up happening regardless at the physical level but I think it's worth fixing the logical level anyway. I don't fully understand the issue: does |
Sorry for not being more clear. I was referring to these lines: datafusion/datafusion/common/src/utils/mod.rs Lines 297 to 298 in 923bfb7
Reading it made me think that if I used quotes I might convince it to remain unchanged, but it still converts to lowercase |
Can we please get a test for this fix so we don't break it again in the future? |
Marking as draft as I think this PR is no longer waiting on feedback and I am trying to make it easier to find PRs in need of review. Please mark it as ready for review when it is ready for another look |
8f13d7f
to
63a09dc
Compare
4df8ec6
to
ba36d39
Compare
@alamb Thanks for waiting, added a test that would break without this change |
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 also suggest adding sqllogictest based on the sql in PR summary
|
||
#[test] | ||
fn filter_agg_case_insensitive() -> Result<()> { | ||
let table_scan = test_table_scan_with_uppercase_columns()?; |
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.
If the table also has a column named 'a', what'll happen?
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.
Great question, just tried this and it works as expected for both uppercase and lower case col, even if both are present in the schema at the same time. I added another test, lmk if we should keep it or it's overkill.
I'd be happy to, can you please point me at a sample patch or a good suite to add to? Last time I tried there was quite a bit of ceremony around SLT, not sure if I can get it right on first approach. Thanks! |
Which issue does this PR close?
PushDownFilter does not push a predicate when the table has columns that are not all lowercase. Tried with and without
enable_ident_normalization
- no change. The logic insideparse_identifiers_normalized
does not seem to properly detect quotes and it will lowercase the column used in the group by expression.Here's the query I used, just for illustration:
Expected query plan:
Actual query plan:
An alterate fix could use
expr_to_columns
to extract the columns, as in Unnest above:Question: should we make the same change in the Window functions branch?
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Yes, from a client application.
I did not add any unit tests, none of the existing tests in this module use upper case columns. Tried to add another table/schema, but then the test was failing, I am unsure of how to control the lowercasing of column names.
Are there any user-facing changes?