-
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][followup] add back UserDefinedFunction.inputTypes #22319
Conversation
Test build #95598 has finished for PR 22319 at commit
|
|
||
private var _nameOption: Option[String] = None | ||
private var _nullable: Boolean = true | ||
private var _deterministic: Boolean = true | ||
|
||
// This is to keep backward compatibility for this case class. | ||
// TODO: revisit this case class in Spark 3.0, and narrow down the public surface. | ||
def inputTypes: Option[Seq[DataType]] = { |
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.
@cloud-fan, I think this still breaks compatibility when UserDefinedFunction
's used in a pattern match.
object UserDefinedFunction { | ||
// This is to keep backward compatibility for this case class. | ||
// TODO: revisit this case class in Spark 3.0, and narrow down the public surface. | ||
def unapply(arg: UserDefinedFunction): Option[(AnyRef, DataType, Option[Seq[DataType]])] = { |
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.
Doesn't this still break binary compatibility since we bind to another signature?
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 checked locally and apparently not - looks explicit unapply here and unapply from case class are handled as the same signature from my cursory test.
@@ -129,3 +135,11 @@ case class UserDefinedFunction protected[sql] ( | |||
} | |||
} | |||
} | |||
|
|||
object UserDefinedFunction { |
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.
private[sql]
since we don't explicitly mention expressions
package is meant to be internal.
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 am okay if this is the only way.
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.
Here I'm adding back the public unapply
method, so this must be public.
Test build #95599 has finished for PR 22319 at commit
|
Test build #95600 has finished for PR 22319 at commit
|
object UserDefinedFunction { | ||
// This is to keep backward compatibility for this case class. | ||
// TODO: revisit this case class in Spark 3.0, and narrow down the public surface. | ||
def unapply(obj: Any): Option[(AnyRef, DataType, Option[Seq[DataType]])] = obj match { |
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.
Wenchen, can we have a small test to check if the previous pattern matching works or not, and can you double check this by mimicking the case by javap -v
manually at least since this looks not being checked?
Test build #95611 has finished for PR 22319 at commit
|
It's too hard to work around the case class compatibility issue. I'm leaving it unchanged, and add private mutable variables to store the nullable info. |
Test build #95626 has finished for PR 22319 at commit
|
I prefer the current way as well. |
Test build #95630 has finished for PR 22319 at commit
|
@@ -41,12 +41,16 @@ import org.apache.spark.sql.types.DataType | |||
case class UserDefinedFunction protected[sql] ( | |||
f: AnyRef, | |||
dataType: DataType, | |||
inputTypes: Option[Seq[ScalaReflection.Schema]]) { | |||
inputTypes: Option[Seq[DataType]]) { |
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.
+1. This is why we added _nameOption, _nullable and _deterministic in 2.3 release.
Please also remove the changes of MimaExcludes.scala made in #22259
Test build #95644 has finished for PR 22319 at commit
|
Test build #95660 has finished for PR 22319 at commit
|
Hm, still need one MiMa exclusion:
|
Shall we update migration guide about the compatibility? |
I've fixed all the compatibility issues. Is there something else we want to let users know? |
Test build #95691 has finished for PR 22319 at commit
|
retest this please |
|
||
// We have to use a name different than `UserDefinedFunction` here, to avoid breaking the binary | ||
// compatibility of the auto-generate UserDefinedFunction object. | ||
private[sql] object SparkUserDefinedFunction { |
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, so we're working around by new object here. SGTM. I assumed mutable status and copy stuff but trivial or not an issue.
LGTM |
Test build #95696 has finished for PR 22319 at commit
|
retest this please |
Test build #95700 has finished for PR 22319 at commit
|
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.
Yeah it is a little hacky internally but maximizes compatibility.
thanks, merging to master! |
What changes were proposed in this pull request?
This is a followup of #22259 .
Scala case class has a wide surface: apply, unapply, accessors, copy, etc.
In #22259 , we change the type of
UserDefinedFunction.inputTypes
fromOption[Seq[DataType]]
toOption[Seq[Schema]]
. This breaks backward compatibility.This PR changes the type back, and use a
var
to keep the new nullable info.How was this patch tested?
N/A