-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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-12258] [SQL] passing null into ScalaUDF (follow-up) #10266
Conversation
I tried it locally, here is my findings:
So I think a simple fix is just adding |
Could you try to add |
Wenchen, should the type of i be Integer? |
I changed |
It's not a Janino bug, |
@davies This results in a slightly different failure from the one I previously reported: Everything looks the same as the prior post except now:
|
@markhamstra Sorry, just pushed a commit to fix it now, added a regression test, could you check it again? |
No problem; I'll cherry-pick another. |
@markhamstra Once it works, I will merge this to unblock RC2. |
LGTM pending tests. |
Still doesn't work for me. Now it ends up in a different place, but a NPE:
|
@markhamstra I think it's because of your UDF did not handle null correctly. |
@davies The exact same UDF worked fine in 1.5. |
Test build #47572 has finished for PR 10266 at commit
|
Test build #2202 has finished for PR 10266 at commit
|
Test build #47574 has finished for PR 10266 at commit
|
hi @markhamstra , can you add some log in your UDF, to see if the NPE occurred before run into your UDF code or after? |
@cloud-fan @markhamstra They should be all fixed (handling null in arguments and results). |
Test build #47578 has finished for PR 10266 at commit
|
boolean ${ev.isNull} = $resultTerm == null; | ||
${ctx.javaType(dataType)} ${ev.value} = ${ctx.defaultValue(dataType)}; | ||
if (!${ev.isNull}) { | ||
${ev.value} = $resultTerm; |
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.
ah that's it, the result type may be primitive and we should not assign null value to it, or NPE will happen.
Should we create a JIRA for it? I think it's a different bug comparing to the one you fixed in #10259
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.
Seems we are fine because we check if (!${ev.isNull})
first?
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.
It will not cause NPE, but a compilation error?
For example, if dataType
is Integer
, line 1049 will be int ev.value = null
This statement will trigger a compilation error incompatible types
. Right?
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.
It's Integer b = null; int a = (Integer) b;
, then NPE
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 can understand your fix, but I am trying to see what @cloud-fan said above. It sounds like he found another issue?
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.
@gatorsmile At line 1049, we are using the default value. For primitive types, it will not be null.
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.
My understanding is that he was trying to explain the NPE reported by @markhamstra.
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.
uh, the value of ${ctx.defaultValue(dataType)}
is not null
but -1
when data type is Integer
. I do not have more questions. Thanks!
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.
sorry for being vague, I was trying to explain why the NPE happened and @davies has fixed it.
Works for me. Thanks, guys! |
test this please |
Test build #47584 has finished for PR 10266 at commit
|
test this please |
Test build #2204 has finished for PR 10266 at commit
|
Test build #2205 has finished for PR 10266 at commit
|
Test build #47585 has finished for PR 10266 at commit
|
This is a follow-up PR for #10259