Use IfExpr to check when input to log2 is <=0 and return null#506
Use IfExpr to check when input to log2 is <=0 and return null#506kazuyukitanimura merged 8 commits intoapache:mainfrom
Conversation
andygrove
left a comment
There was a problem hiding this comment.
This is looking good so far. Thanks @PedroMDuarte
| )); | ||
|
|
||
| Ok(scalar_expr) | ||
| match fun_name.as_str() { |
There was a problem hiding this comment.
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.
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.
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! |
andygrove
left a comment
There was a problem hiding this comment.
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,log2andlog10was modified so that it includes negative numbers as part of the inputs being tested.