Skip to content
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

Closed
wants to merge 9 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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]] = {
Copy link
Member

@HyukjinKwon HyukjinKwon Sep 3, 2018

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.

inputSchemas.map(_.map(_.dataType))
}

/**
* Returns true when the UDF can return a nullable value.
*
Expand All @@ -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 = {
Expand Down