-
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
Changes from 2 commits
e9c6fbc
5acb1df
2245395
01a51ca
c77db87
d290fec
4791240
2b2c894
9e060a4
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 |
---|---|---|
|
@@ -41,12 +41,18 @@ import org.apache.spark.sql.types.DataType | |
case class UserDefinedFunction protected[sql] ( | ||
f: AnyRef, | ||
dataType: DataType, | ||
inputTypes: Option[Seq[ScalaReflection.Schema]]) { | ||
inputSchemas: Option[Seq[ScalaReflection.Schema]]) { | ||
|
||
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]] = { | ||
inputSchemas.map(_.map(_.dataType)) | ||
} | ||
|
||
/** | ||
* Returns true when the UDF can return a nullable value. | ||
* | ||
|
@@ -73,11 +79,11 @@ case class UserDefinedFunction protected[sql] ( | |
f, | ||
dataType, | ||
exprs.map(_.expr), | ||
inputTypes.map(_.map(_.dataType)).getOrElse(Nil), | ||
inputSchemas.map(_.map(_.dataType)).getOrElse(Nil), | ||
udfName = _nameOption, | ||
nullable = _nullable, | ||
udfDeterministic = _deterministic, | ||
nullableTypes = inputTypes.map(_.map(_.nullable)).getOrElse(Nil))) | ||
nullableTypes = inputSchemas.map(_.map(_.nullable)).getOrElse(Nil))) | ||
} | ||
|
||
private def copyAll(): UserDefinedFunction = { | ||
|
@@ -129,3 +135,11 @@ case class UserDefinedFunction protected[sql] ( | |
} | ||
} | ||
} | ||
|
||
object UserDefinedFunction { | ||
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.
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 am okay if this is the only way. 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. Here I'm adding back the public |
||
// 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 commentThe 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 commentThe 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. |
||
Some(arg.f, arg.dataType, arg.inputSchemas.map(_.map(_.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.