-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-8280][SPARK-8281][SQL]Handle NaN, null and Infinity in math #6835
Conversation
Jenkins, ok to test. |
Test build #34973 has finished for PR 6835 at commit
|
Test build #34977 has finished for PR 6835 at commit
|
override def genCode(ctx: CodeGenContext, ev: GeneratedExpressionCode): String = { | ||
val eval = child.gen(ctx) | ||
eval.code + s""" | ||
boolean ${ev.isNull} = ${eval.isNull} || Double.valueOf(${eval.primitive}) <= 0.0; |
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.
isn't this just
${eval.primitive} <= 0.0
instead of calling Double.valueOf?
@YijieSHEN it'd make sense to merge this after #6725 It might change your code here. |
btw I was thinking maybe Log2 and the other log functions can just be child class of the Logarithm class added in #6725? |
I've merged #6725 in the latest commit. Also tried to refactor all the log functions to subclass the Logarithm class added there, but find wried and hard to understand then, so just discard that version. |
Test build #35139 has finished for PR 6835 at commit
|
Test build #35141 has finished for PR 6835 at commit
|
// math.log(evalE2.asInstanceOf[Double]) / math.log(evalE1.asInstanceOf[Double]) | ||
// } | ||
// } | ||
// } |
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.
Hive's UDFLog doesn't support base in range (0.0, 1.0], it would just eval to null in this case, just act as the commented out code above.
I'm not sure it we also want to behave like this, any ideas?
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.
we should support these. just remove the commented code, and add to inline comment for log that we support (0.0, 1.0], unlike hive.
Test build #35150 has finished for PR 6835 at commit
|
Test build #35629 has finished for PR 6835 at commit
|
Seems build failure is not related to this PR |
retest this please. |
The MiMa test failure is due to an artifact missing from a Maven staging repository; I have opened #6974 to hotfix. |
Jenkins, retest this please. |
Test build #35645 has finished for PR 6835 at commit
|
@@ -259,19 +285,14 @@ case class Atan2(left: Expression, right: Expression) | |||
null | |||
} else { | |||
// With codegen, the values returned by -0.0 and 0.0 are different. Handled with +0.0 | |||
val result = math.atan2(evalE1.asInstanceOf[Double] + 0.0, | |||
math.atan2(evalE1.asInstanceOf[Double] + 0.0, |
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 don't think u need to wrap here.
@YijieSHEN can you bring this up to date? |
@rxin, do you mind my closing this one and creating a new pr for this? The base code is quite outdated. |
Not at all. Feel free to close this one and submit a new one. |
ok, will do soon |
close this and continue in #7451 |
Just as their counterparts in Hive:
UDFAsin
&UDFAcos
would just return NaN if its argument is NaN or its absolute value is greater than 1, therefore I think it's enough to just remove NaN checking before return.Log*
would first checkargument <= 0.0
and return null for 0.0 instead of-Infinity