-
Notifications
You must be signed in to change notification settings - Fork 166
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
Use IfExpr to check when input to log2 is <=0 and return null #506
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.
This is looking good so far. Thanks @PedroMDuarte
@@ -1397,7 +1397,18 @@ impl PhysicalPlanner { | |||
args.is_empty(), | |||
)); | |||
|
|||
Ok(scalar_expr) | |||
match fun_name.as_str() { |
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.
Hmm, please don't put this special handling in create_scalar_function_expr
. Could you move it to create_comet_physical_fun
where special handling of scalar functions should be located?
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 for bringing that up!
Just to clarify, if we were to do this as part of create_comet_physical_fun
then it would be all reimplemented at a lower level and not able to reuse the Datafusion Log2 implementation via an IfExpr. Is that right?
Happy to go either way. @andygrove's original hint mentioned using IfExpr, but I couldn't quite get that working inside of create_comet_physical_fun
because it doesn't have access to the arg exprs.
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.
Apologies for the delay in responding here. I will start reviewing this on Monday.
I would rather do this in QueryPlanSerde, E.g.
See |
thanks for this suggestion! |
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.
LGTM pending CI. I confirmed that the change to the unit test does demonstrate the incorrect behavior. Thanks @PedroMDuarte
Could you also update this section in expressions.md
|
spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
Outdated
Show resolved
Hide resolved
|
thanks for the guidance here, really appreciate you all taking the time to show me how to contribute this fix. |
Merged, thanks @PedroMDuarte @andygrove |
And thanks @viirya |
…#506) ## Which issue does this PR close? Closes apache#485 ## Rationale for this change Compatibility with how Spark handles logarithms of values <=0. ## What changes are included in this PR? Use IfExpr to check when input to log2 is <=0 and return null. This is done to match Spark's behavior, which in turn is implemented to match Hive's behavior. ## How are these changes tested? The existing test for `ln`, `log2` and `log10` was modified so that it includes negative numbers as part of the inputs being tested.
Which issue does this PR close?
Closes #485
Rationale for this change
Compatibility with how Spark handles logarithms of values <=0.
What changes are included in this PR?
Use IfExpr to check when input to log2 is <=0 and return null. This is done to match Spark's behavior, which in turn is implemented to match Hive's behavior.
How are these changes tested?
The existing test for
ln
,log2
andlog10
was modified so that it includes negative numbers as part of the inputs being tested.