Skip to content
Closed
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
fix
  • Loading branch information
Ngone51 committed May 29, 2020
commit 8576d283cca15366aa86e01a7826345865308fd5
Original file line number Diff line number Diff line change
Expand Up @@ -2858,9 +2858,10 @@ class Analyzer(
if encoders.nonEmpty && desers.isEmpty =>
val deserializers = encoders.zipWithIndex.map { case (encOpt, i) =>
val dataType = inputs(i).dataType
if (CatalystTypeConverters.isPrimitive(dataType)) {
// primitive data types do not rely on `ExpressionEncoder` to
// convert data, see `ScalaUDF.scalaConverter`.
if (CatalystTypeConverters.isPrimitive(dataType) ||
dataType.isInstanceOf[UserDefinedType[_]]) {
// primitive/UDT data types use `CatalystTypeConverters` to
// convert internal data to external data.
None
} else {
encOpt.map { enc =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ case class ScalaUDF(

override lazy val deterministic: Boolean = udfDeterministic && children.forall(_.deterministic)

override lazy val canonicalized: Expression = {
val canonicalizedChildren = children.map(_.canonicalized)
// if the canonicalized children and inputEncoders are equal,
// then we must have equal inputDeserializers as well.
this.copy(inputDeserializers = Nil).withNewChildren(canonicalizedChildren)
}

override def toString: String = s"${udfName.getOrElse("UDF")}(${children.mkString(", ")})"

/**
Expand Down Expand Up @@ -127,6 +134,7 @@ case class ScalaUDF(
fromRow(row)
}

// e.g. for UDF types
case _ => createToScalaConverter(dataType)
}
}
Expand Down