-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 line that prevents display_name from being called on Wildcard #4682
Add line that prevents display_name from being called on Wildcard #4682
Conversation
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.
Thanks @andre-cc-natzka
I think this change is fine and we could merge it as is -- however, I suggest we update Expr::display_name
instead
datafusion/optimizer/src/utils.rs
Outdated
@@ -583,6 +583,7 @@ where | |||
fn name_for_alias(expr: &Expr) -> Result<String> { | |||
match expr { | |||
Expr::Sort { expr, .. } => name_for_alias(expr), | |||
Expr::Wildcard => Ok("*".to_string()), | |||
expr => expr.display_name(), |
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.
As you note in your PR description, another way to fix this would be to support Expr::Wildcard
in Expr::display_name
Unless there is some reason to not support WildCard
s in Expr::display_name
I would personally prefer adding the support there. It seems strange to put code for Wildcard in a function that seem to be trying to unwrap Expr::Sort
s 🤔
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 very much @alamb! I agree with you, so I've just moved that line to the create_name
function called by Expr::display_name
. If this is fine for you, I guess we can merge it.
Benchmark runs are scheduled for baseline = ac2e5d1 and contender = bfef105. bfef105 is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |
Thanks for taking care of this! Have a Merry Christmas :) |
Which issue does this PR close?
Closes #4681.
Rationale for this change
As detailed in the issue, there was a problem with
create_name()
being called onExpr::Wildcard
in thetype_coercion
andunwrap_cast_in_comparison
optimization rules, which eventually led to these optimization rules not being applied.What changes are included in this PR?
In the issue description, two different solutions were suggested. Here, I chose the first one, i.e. to add one line to the
name_for_alias
function, ensuring that we individualize theExpr::Wildcard
case, and naming the expression in a reasonable way (e.g. "*") instead of callingdisplay_name()
.Are these changes tested?
No tests were added in this PR, but we tested the code with the suggested change on our own and the bug is solved, since the warnings are gone and the optimization rules are applied as intended.
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
We still want to hear what you think about the best way to solve the issue.
If there are user-facing changes then we may require documentation to be updated before approving the PR.
No.
If there are any breaking changes to public APIs, please add the
api change
label.No.