-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Planner: normalize_ident only when enable_ident_normalization is enabled #5785
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
Conversation
… to honor planner options
|
While working on this PR, I also noticed that there are places not related to the planner which also normalize names such as column. I wonder if it's valuable to also make these method configurable to enable ident normalization? |
I had some thoughts about this previously (not this specific function, but still applicable): #5183 (comment) Generally I'm not sure how exactly to be able to toggle normalization at that level (the common crate) without API changes to dependent functions, like |
alamb
left a comment
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.
Thank you @ayushdg
I have some suggestions on how maybe to make this code better, but I also think what is here is better than what is on master so it could be merged as is.
datafusion/sql/src/planner.rs
Outdated
| } | ||
|
|
||
| fn normalize_ident(id: Ident, enable_normalization: bool) -> String { | ||
| pub fn normalize_ident(id: Ident, enable_normalization: bool) -> String { |
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.
What would you think about making crate::utils::normalize_ident pub instead? making something public that only does something if true is passed in seems somewhat strange to me
|
@ayushdg please let me know if you would to make changes to this PR or if we should merge it as is |
…r-ident-normalization
…ent to the struct implementation
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.
In cases like this with helper methods that get called from SqlToRel impl methods is there a better approach than adding a normalizer argument to each of these methods?
https://github.com/apache/arrow-datafusion/blob/c5e935a15f22d16d8ca244e68b128f7c5ff28375/datafusion/sql/src/statement.rs#L54-L65
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 can't think of any at the moment
alamb
left a comment
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 good to me -- thank you @ayushdg
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 can't think of any at the moment
|
Thanks @alamb let me know if anything else is needed, or if the pr is good to merge as is. |
…led (apache#5785) * Make planner::normalize_ident public and refactor planner impl method to honor planner options * Undo pre-commit config change * Add tests * Add identNormalizer struct to sqlToRel and move calls to normalize_ident to the struct implementation
Which issue does this PR close?
Closes #5626
Rationale for this change
Some part of the codebase use
sqlToRel's options forenable_ident_normalizationto decide whether to normalize identifiers or not, but it isn't enforced consistently throughout the codebase.What changes are included in this PR?
Make planner:normalize_ident public.
All methods implementing
SqlToReluseenable_ident_normalizationwhile normalizing.Are these changes tested?
Are there any user-facing changes?
No.