-
Notifications
You must be signed in to change notification settings - Fork 29k
[WIP][SPARK-25044][SQL] Address translation of LMF closure primitive args to Object in Scala 2.12 #22063
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
[WIP][SPARK-25044][SQL] Address translation of LMF closure primitive args to Object in Scala 2.12 #22063
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 |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ | |
| package org.apache.spark.ml.classification | ||
|
|
||
| import org.apache.spark.SparkException | ||
| import org.apache.spark.annotation.{DeveloperApi, Since} | ||
| import org.apache.spark.annotation.DeveloperApi | ||
| import org.apache.spark.ml.{PredictionModel, Predictor, PredictorParams} | ||
| import org.apache.spark.ml.feature.LabeledPoint | ||
| import org.apache.spark.ml.linalg.{Vector, VectorUDT} | ||
|
|
@@ -164,8 +164,8 @@ abstract class ClassificationModel[FeaturesType, M <: ClassificationModel[Featur | |
| var outputData = dataset | ||
| var numColsOutput = 0 | ||
| if (getRawPredictionCol != "") { | ||
| val predictRawUDF = udf { (features: Any) => | ||
|
||
| predictRaw(features.asInstanceOf[FeaturesType]) | ||
| val predictRawUDF = udfInternal { features: FeaturesType => | ||
| predictRaw(features) | ||
| } | ||
| outputData = outputData.withColumn(getRawPredictionCol, predictRawUDF(col(getFeaturesCol))) | ||
| numColsOutput += 1 | ||
|
|
@@ -174,8 +174,8 @@ abstract class ClassificationModel[FeaturesType, M <: ClassificationModel[Featur | |
| val predUDF = if (getRawPredictionCol != "") { | ||
| udf(raw2prediction _).apply(col(getRawPredictionCol)) | ||
| } else { | ||
| val predictUDF = udf { (features: Any) => | ||
| predict(features.asInstanceOf[FeaturesType]) | ||
| val predictUDF = udfInternal { features: FeaturesType => | ||
| predict(features) | ||
| } | ||
| predictUDF(col(getFeaturesCol)) | ||
| } | ||
|
|
||
| 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) | ||
| 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.
I'm really surprised that this worked before...