-
Notifications
You must be signed in to change notification settings - Fork 28.4k
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-25044][SQL] (take 2) Address translation of LMF closure primitive args to Object in Scala 2.12 #22259
Changes from all commits
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 |
---|---|---|
|
@@ -39,6 +39,7 @@ import org.apache.spark.sql.types.DataType | |
* @param nullable True if the UDF can return null value. | ||
* @param udfDeterministic True if the UDF is deterministic. Deterministic UDF returns same result | ||
* each time it is invoked with a particular input. | ||
* @param nullableTypes which of the inputTypes are nullable (i.e. not primitive) | ||
*/ | ||
case class ScalaUDF( | ||
function: AnyRef, | ||
|
@@ -47,7 +48,8 @@ case class ScalaUDF( | |
inputTypes: Seq[DataType] = Nil, | ||
udfName: Option[String] = None, | ||
nullable: Boolean = true, | ||
udfDeterministic: Boolean = true) | ||
udfDeterministic: Boolean = true, | ||
nullableTypes: Seq[Boolean] = Nil) | ||
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. Using Nil as the default value is dangerous. We even do not have an assert to ensure it is set. We could easily miss the setting without the right values. 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. We put the assert in the rule can we merge 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 logic here was again that we wanted to avoid changing the binary signature. I know catalyst is effectively private to Spark, but this wasn't marked specifically private; I wondered if it would actually affect callers? If not we can go back and merge it. Nil is just an empty list; I don't think it's dangerous and it is used above in 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. I think the problem is more about the way we handle 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. I see, you are saying that some UDF needed to declare nullable types but didn't? I made the param optional to try to make 'migration' easier and avoid changing the signature much. But, the test you point to, doesn't it pass? are you saying it should not pass? 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. Yeah I could see an argument that it need not block release. The functionality works as intended, at least. Would you change it again in 2.4.1? If not then we decide to just keep this behavior. Let's say at least get this in if there is a new RC. 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. Yeah I could see an argument that it need not block release. The functionality works as intended, at least. Would you change it again in 2.4.1? If not then we decide to just keep this behavior. Let's say at least get this in if there is a new RC. 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. I think it's mostly about maintainability. We should definitely update the code as @maryannxue said, so that 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. @maryannxue Please submit a PR to make the parameter 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. Yeah looks like we should just make these changes after all, and for 2.4, as we need another RC. |
||
extends Expression with ImplicitCastInputTypes with NonSQLExpression with UserDefinedExpression { | ||
|
||
// The constructor for SPARK 2.1 and 2.2 | ||
|
@@ -58,7 +60,8 @@ case class ScalaUDF( | |
inputTypes: Seq[DataType], | ||
udfName: Option[String]) = { | ||
this( | ||
function, dataType, children, inputTypes, udfName, nullable = true, udfDeterministic = true) | ||
function, dataType, children, inputTypes, udfName, nullable = true, | ||
udfDeterministic = true, nullableTypes = Nil) | ||
} | ||
|
||
override lazy val deterministic: Boolean = udfDeterministic && children.forall(_.deterministic) | ||
|
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.
nit: can we restore the spaces as in the original?
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 missed it. We can clean it up later.
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 might be missing it - what is the space issue? There's an additional level of indent because of the if statement
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 is in
udf@ScalaUDF
which should have beenudf @ ScalaUDF
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.
Oh right. Yeah I didn't mean to change that. It's minor enough to leave I think. (or else standardize across the code)