-
Notifications
You must be signed in to change notification settings - Fork 0
3797: fix: query tolerance= in SQL file tests now also asserts Comet native execution #50
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?
Changes from all commits
591d3fb
e4ba906
e07dfd8
c9b53d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,7 +19,7 @@ | |||||||||||||||||||
|
|
||||||||||||||||||||
| package org.apache.comet.serde | ||||||||||||||||||||
|
|
||||||||||||||||||||
| import org.apache.spark.sql.catalyst.expressions.{Abs, Atan2, Attribute, Ceil, CheckOverflow, Expression, Floor, Hex, If, LessThanOrEqual, Literal, Log, Log10, Log2, Tan, Unhex} | ||||||||||||||||||||
| import org.apache.spark.sql.catalyst.expressions.{Abs, Atan2, Attribute, Ceil, CheckOverflow, Expression, Floor, Hex, If, LessThanOrEqual, Literal, Log, Log10, Log2, Logarithm, Tan, Unhex} | ||||||||||||||||||||
| import org.apache.spark.sql.types.{DecimalType, NumericType} | ||||||||||||||||||||
|
|
||||||||||||||||||||
| import org.apache.comet.CometSparkSessionExtensions.withInfo | ||||||||||||||||||||
|
|
@@ -138,6 +138,20 @@ object CometLog2 extends CometExpressionSerde[Log2] with MathExprBase { | |||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| object CometLogarithm extends CometExpressionSerde[Logarithm] with MathExprBase { | ||||||||||||||||||||
| override def convert( | ||||||||||||||||||||
| expr: Logarithm, | ||||||||||||||||||||
| inputs: Seq[Attribute], | ||||||||||||||||||||
| binding: Boolean): Option[ExprOuterClass.Expr] = { | ||||||||||||||||||||
| // Spark's Logarithm(left=base, right=value) returns null when result is NaN, | ||||||||||||||||||||
| // which happens when base <= 0 or value <= 0. Apply nullIfNegative to both. | ||||||||||||||||||||
| val leftExpr = exprToProtoInternal(nullIfNegative(expr.left), inputs, binding) | ||||||||||||||||||||
| val rightExpr = exprToProtoInternal(nullIfNegative(expr.right), inputs, binding) | ||||||||||||||||||||
|
Comment on lines
+146
to
+149
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current implementation of To align with Spark's behavior, you should add a check to return
Suggested change
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. value:annoying; category:bug; feedback: The Gemini AI reviewer is not correct! It returns |
||||||||||||||||||||
| val optExpr = scalarFunctionExprToProto("log", leftExpr, rightExpr) | ||||||||||||||||||||
| optExprWithInfo(optExpr, expr, expr.left, expr.right) | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CometLogarithm mishandles NaN inputs producing NaN instead of nullHigh Severity
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. value:annoying; category:bug; feedback: The Bugbot AI reviewer is not correct! Apache Spark 4.0.2 returns NaN here, not NULL. |
||||||||||||||||||||
|
|
||||||||||||||||||||
| object CometHex extends CometExpressionSerde[Hex] with MathExprBase { | ||||||||||||||||||||
| override def convert( | ||||||||||||||||||||
| expr: Hex, | ||||||||||||||||||||
|
|
||||||||||||||||||||


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.
The comment says Spark returns null when the result is NaN, but for log functions Spark/Hive semantics are generally “non-positive inputs => null” (e.g.,
log(..., 0)would otherwise yield-Infinity, notNaN). This wording could mislead future changes to the null-guard logic.Severity: low
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
Uh oh!
There was an error while loading. Please reload this page.
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.
value:useful; category:documentation; feedback: The Augment AI reviewer is correct! The comment says that
NaNresults are converted toNULLbutvalue=0leads to an-Infinityresult, which is also treated as NULL by Apache Spark. Prevents committing a confusing comment.