Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/20141#discussion_r159439570
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/UDFRegistration.scala ---
@@ -110,29 +110,29 @@ class UDFRegistration private[sql] (functionRegistry:
FunctionRegistry) extends
/* register 0-22 were generated by this script
- (0 to 22).map { x =>
+ (0 to 22).foreach { x =>
val types = (1 to x).foldRight("RT")((i, s) => {s"A$i, $s"})
- val typeTags = (1 to x).map(i => s"A${i}: TypeTag").foldLeft("RT:
TypeTag")(_ + ", " + _)
+ val typeTags = (1 to x).map(i => s"A$i: TypeTag").foldLeft("RT:
TypeTag")(_ + ", " + _)
val inputTypes = (1 to x).foldRight("Nil")((i, s) =>
{s"ScalaReflection.schemaFor[A$i].dataType :: $s"})
println(s"""
- /**
- * Registers a deterministic Scala closure of ${x} arguments as
user-defined function (UDF).
- * @tparam RT return type of UDF.
- * @since 1.3.0
- */
- def register[$typeTags](name: String, func: Function$x[$types]):
UserDefinedFunction = {
- val ScalaReflection.Schema(dataType, nullable) =
ScalaReflection.schemaFor[RT]
- val inputTypes = Try($inputTypes).toOption
- def builder(e: Seq[Expression]) = if (e.length == $x) {
- ScalaUDF(func, dataType, e, inputTypes.getOrElse(Nil),
Some(name), nullable, udfDeterministic = true)
- } else {
- throw new AnalysisException("Invalid number of arguments for
function " + name +
- ". Expected: $x; Found: " + e.length)
- }
- functionRegistry.createOrReplaceTempFunction(name, builder)
- val udf = UserDefinedFunction(func, dataType,
inputTypes).withName(name)
- if (nullable) udf else udf.asNonNullable()
- }""")
+ |/**
--- End diff --
just code style change, to use the multiline string format.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]