|
|
|
@ -58,8 +58,10 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
* Register a user-defined aggregate function (UDAF).
|
|
|
|
|
*
|
|
|
|
|
* @param name the name of the UDAF.
|
|
|
|
|
* @param udaf the UDAF needs to be registered.
|
|
|
|
|
* @param udaf the UDAF that needs to be registered.
|
|
|
|
|
* @return the registered UDAF.
|
|
|
|
|
*
|
|
|
|
|
* @since 1.5.0
|
|
|
|
|
*/
|
|
|
|
|
def register(
|
|
|
|
|
name: String,
|
|
|
|
@ -69,6 +71,22 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
udaf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Register a user-defined function (UDF).
|
|
|
|
|
*
|
|
|
|
|
* @param name the name of the UDF.
|
|
|
|
|
* @param udf the UDF that needs to be registered.
|
|
|
|
|
* @return the registered UDF.
|
|
|
|
|
*
|
|
|
|
|
* @since 1.6.0
|
|
|
|
|
*/
|
|
|
|
|
def register(
|
|
|
|
|
name: String,
|
|
|
|
|
udf: UserDefinedFunction): UserDefinedFunction = {
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// scalastyle:off
|
|
|
|
|
|
|
|
|
|
/* register 0-22 were generated by this script
|
|
|
|
@ -86,9 +104,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[$typeTags](name: String, func: Function$x[$types]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try($inputTypes).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}""")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -118,9 +136,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag](name: String, func: Function0[RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -131,9 +149,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag, A1: TypeTag](name: String, func: Function1[A1, RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(ScalaReflection.schemaFor[A1].dataType :: Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -144,9 +162,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag, A1: TypeTag, A2: TypeTag](name: String, func: Function2[A1, A2, RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(ScalaReflection.schemaFor[A1].dataType :: ScalaReflection.schemaFor[A2].dataType :: Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -157,9 +175,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag](name: String, func: Function3[A1, A2, A3, RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(ScalaReflection.schemaFor[A1].dataType :: ScalaReflection.schemaFor[A2].dataType :: ScalaReflection.schemaFor[A3].dataType :: Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -170,9 +188,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag](name: String, func: Function4[A1, A2, A3, A4, RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(ScalaReflection.schemaFor[A1].dataType :: ScalaReflection.schemaFor[A2].dataType :: ScalaReflection.schemaFor[A3].dataType :: ScalaReflection.schemaFor[A4].dataType :: Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -183,9 +201,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag](name: String, func: Function5[A1, A2, A3, A4, A5, RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(ScalaReflection.schemaFor[A1].dataType :: ScalaReflection.schemaFor[A2].dataType :: ScalaReflection.schemaFor[A3].dataType :: ScalaReflection.schemaFor[A4].dataType :: ScalaReflection.schemaFor[A5].dataType :: Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -196,9 +214,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag, A6: TypeTag](name: String, func: Function6[A1, A2, A3, A4, A5, A6, RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(ScalaReflection.schemaFor[A1].dataType :: ScalaReflection.schemaFor[A2].dataType :: ScalaReflection.schemaFor[A3].dataType :: ScalaReflection.schemaFor[A4].dataType :: ScalaReflection.schemaFor[A5].dataType :: ScalaReflection.schemaFor[A6].dataType :: Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -209,9 +227,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag, A6: TypeTag, A7: TypeTag](name: String, func: Function7[A1, A2, A3, A4, A5, A6, A7, RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(ScalaReflection.schemaFor[A1].dataType :: ScalaReflection.schemaFor[A2].dataType :: ScalaReflection.schemaFor[A3].dataType :: ScalaReflection.schemaFor[A4].dataType :: ScalaReflection.schemaFor[A5].dataType :: ScalaReflection.schemaFor[A6].dataType :: ScalaReflection.schemaFor[A7].dataType :: Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -222,9 +240,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag, A6: TypeTag, A7: TypeTag, A8: TypeTag](name: String, func: Function8[A1, A2, A3, A4, A5, A6, A7, A8, RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(ScalaReflection.schemaFor[A1].dataType :: ScalaReflection.schemaFor[A2].dataType :: ScalaReflection.schemaFor[A3].dataType :: ScalaReflection.schemaFor[A4].dataType :: ScalaReflection.schemaFor[A5].dataType :: ScalaReflection.schemaFor[A6].dataType :: ScalaReflection.schemaFor[A7].dataType :: ScalaReflection.schemaFor[A8].dataType :: Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -235,9 +253,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag, A6: TypeTag, A7: TypeTag, A8: TypeTag, A9: TypeTag](name: String, func: Function9[A1, A2, A3, A4, A5, A6, A7, A8, A9, RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(ScalaReflection.schemaFor[A1].dataType :: ScalaReflection.schemaFor[A2].dataType :: ScalaReflection.schemaFor[A3].dataType :: ScalaReflection.schemaFor[A4].dataType :: ScalaReflection.schemaFor[A5].dataType :: ScalaReflection.schemaFor[A6].dataType :: ScalaReflection.schemaFor[A7].dataType :: ScalaReflection.schemaFor[A8].dataType :: ScalaReflection.schemaFor[A9].dataType :: Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -248,9 +266,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag, A6: TypeTag, A7: TypeTag, A8: TypeTag, A9: TypeTag, A10: TypeTag](name: String, func: Function10[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(ScalaReflection.schemaFor[A1].dataType :: ScalaReflection.schemaFor[A2].dataType :: ScalaReflection.schemaFor[A3].dataType :: ScalaReflection.schemaFor[A4].dataType :: ScalaReflection.schemaFor[A5].dataType :: ScalaReflection.schemaFor[A6].dataType :: ScalaReflection.schemaFor[A7].dataType :: ScalaReflection.schemaFor[A8].dataType :: ScalaReflection.schemaFor[A9].dataType :: ScalaReflection.schemaFor[A10].dataType :: Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -261,9 +279,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag, A6: TypeTag, A7: TypeTag, A8: TypeTag, A9: TypeTag, A10: TypeTag, A11: TypeTag](name: String, func: Function11[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(ScalaReflection.schemaFor[A1].dataType :: ScalaReflection.schemaFor[A2].dataType :: ScalaReflection.schemaFor[A3].dataType :: ScalaReflection.schemaFor[A4].dataType :: ScalaReflection.schemaFor[A5].dataType :: ScalaReflection.schemaFor[A6].dataType :: ScalaReflection.schemaFor[A7].dataType :: ScalaReflection.schemaFor[A8].dataType :: ScalaReflection.schemaFor[A9].dataType :: ScalaReflection.schemaFor[A10].dataType :: ScalaReflection.schemaFor[A11].dataType :: Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -274,9 +292,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag, A6: TypeTag, A7: TypeTag, A8: TypeTag, A9: TypeTag, A10: TypeTag, A11: TypeTag, A12: TypeTag](name: String, func: Function12[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(ScalaReflection.schemaFor[A1].dataType :: ScalaReflection.schemaFor[A2].dataType :: ScalaReflection.schemaFor[A3].dataType :: ScalaReflection.schemaFor[A4].dataType :: ScalaReflection.schemaFor[A5].dataType :: ScalaReflection.schemaFor[A6].dataType :: ScalaReflection.schemaFor[A7].dataType :: ScalaReflection.schemaFor[A8].dataType :: ScalaReflection.schemaFor[A9].dataType :: ScalaReflection.schemaFor[A10].dataType :: ScalaReflection.schemaFor[A11].dataType :: ScalaReflection.schemaFor[A12].dataType :: Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -287,9 +305,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag, A6: TypeTag, A7: TypeTag, A8: TypeTag, A9: TypeTag, A10: TypeTag, A11: TypeTag, A12: TypeTag, A13: TypeTag](name: String, func: Function13[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(ScalaReflection.schemaFor[A1].dataType :: ScalaReflection.schemaFor[A2].dataType :: ScalaReflection.schemaFor[A3].dataType :: ScalaReflection.schemaFor[A4].dataType :: ScalaReflection.schemaFor[A5].dataType :: ScalaReflection.schemaFor[A6].dataType :: ScalaReflection.schemaFor[A7].dataType :: ScalaReflection.schemaFor[A8].dataType :: ScalaReflection.schemaFor[A9].dataType :: ScalaReflection.schemaFor[A10].dataType :: ScalaReflection.schemaFor[A11].dataType :: ScalaReflection.schemaFor[A12].dataType :: ScalaReflection.schemaFor[A13].dataType :: Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -300,9 +318,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag, A6: TypeTag, A7: TypeTag, A8: TypeTag, A9: TypeTag, A10: TypeTag, A11: TypeTag, A12: TypeTag, A13: TypeTag, A14: TypeTag](name: String, func: Function14[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(ScalaReflection.schemaFor[A1].dataType :: ScalaReflection.schemaFor[A2].dataType :: ScalaReflection.schemaFor[A3].dataType :: ScalaReflection.schemaFor[A4].dataType :: ScalaReflection.schemaFor[A5].dataType :: ScalaReflection.schemaFor[A6].dataType :: ScalaReflection.schemaFor[A7].dataType :: ScalaReflection.schemaFor[A8].dataType :: ScalaReflection.schemaFor[A9].dataType :: ScalaReflection.schemaFor[A10].dataType :: ScalaReflection.schemaFor[A11].dataType :: ScalaReflection.schemaFor[A12].dataType :: ScalaReflection.schemaFor[A13].dataType :: ScalaReflection.schemaFor[A14].dataType :: Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -313,9 +331,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag, A6: TypeTag, A7: TypeTag, A8: TypeTag, A9: TypeTag, A10: TypeTag, A11: TypeTag, A12: TypeTag, A13: TypeTag, A14: TypeTag, A15: TypeTag](name: String, func: Function15[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(ScalaReflection.schemaFor[A1].dataType :: ScalaReflection.schemaFor[A2].dataType :: ScalaReflection.schemaFor[A3].dataType :: ScalaReflection.schemaFor[A4].dataType :: ScalaReflection.schemaFor[A5].dataType :: ScalaReflection.schemaFor[A6].dataType :: ScalaReflection.schemaFor[A7].dataType :: ScalaReflection.schemaFor[A8].dataType :: ScalaReflection.schemaFor[A9].dataType :: ScalaReflection.schemaFor[A10].dataType :: ScalaReflection.schemaFor[A11].dataType :: ScalaReflection.schemaFor[A12].dataType :: ScalaReflection.schemaFor[A13].dataType :: ScalaReflection.schemaFor[A14].dataType :: ScalaReflection.schemaFor[A15].dataType :: Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -326,9 +344,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag, A6: TypeTag, A7: TypeTag, A8: TypeTag, A9: TypeTag, A10: TypeTag, A11: TypeTag, A12: TypeTag, A13: TypeTag, A14: TypeTag, A15: TypeTag, A16: TypeTag](name: String, func: Function16[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(ScalaReflection.schemaFor[A1].dataType :: ScalaReflection.schemaFor[A2].dataType :: ScalaReflection.schemaFor[A3].dataType :: ScalaReflection.schemaFor[A4].dataType :: ScalaReflection.schemaFor[A5].dataType :: ScalaReflection.schemaFor[A6].dataType :: ScalaReflection.schemaFor[A7].dataType :: ScalaReflection.schemaFor[A8].dataType :: ScalaReflection.schemaFor[A9].dataType :: ScalaReflection.schemaFor[A10].dataType :: ScalaReflection.schemaFor[A11].dataType :: ScalaReflection.schemaFor[A12].dataType :: ScalaReflection.schemaFor[A13].dataType :: ScalaReflection.schemaFor[A14].dataType :: ScalaReflection.schemaFor[A15].dataType :: ScalaReflection.schemaFor[A16].dataType :: Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -339,9 +357,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag, A6: TypeTag, A7: TypeTag, A8: TypeTag, A9: TypeTag, A10: TypeTag, A11: TypeTag, A12: TypeTag, A13: TypeTag, A14: TypeTag, A15: TypeTag, A16: TypeTag, A17: TypeTag](name: String, func: Function17[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(ScalaReflection.schemaFor[A1].dataType :: ScalaReflection.schemaFor[A2].dataType :: ScalaReflection.schemaFor[A3].dataType :: ScalaReflection.schemaFor[A4].dataType :: ScalaReflection.schemaFor[A5].dataType :: ScalaReflection.schemaFor[A6].dataType :: ScalaReflection.schemaFor[A7].dataType :: ScalaReflection.schemaFor[A8].dataType :: ScalaReflection.schemaFor[A9].dataType :: ScalaReflection.schemaFor[A10].dataType :: ScalaReflection.schemaFor[A11].dataType :: ScalaReflection.schemaFor[A12].dataType :: ScalaReflection.schemaFor[A13].dataType :: ScalaReflection.schemaFor[A14].dataType :: ScalaReflection.schemaFor[A15].dataType :: ScalaReflection.schemaFor[A16].dataType :: ScalaReflection.schemaFor[A17].dataType :: Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -352,9 +370,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag, A6: TypeTag, A7: TypeTag, A8: TypeTag, A9: TypeTag, A10: TypeTag, A11: TypeTag, A12: TypeTag, A13: TypeTag, A14: TypeTag, A15: TypeTag, A16: TypeTag, A17: TypeTag, A18: TypeTag](name: String, func: Function18[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(ScalaReflection.schemaFor[A1].dataType :: ScalaReflection.schemaFor[A2].dataType :: ScalaReflection.schemaFor[A3].dataType :: ScalaReflection.schemaFor[A4].dataType :: ScalaReflection.schemaFor[A5].dataType :: ScalaReflection.schemaFor[A6].dataType :: ScalaReflection.schemaFor[A7].dataType :: ScalaReflection.schemaFor[A8].dataType :: ScalaReflection.schemaFor[A9].dataType :: ScalaReflection.schemaFor[A10].dataType :: ScalaReflection.schemaFor[A11].dataType :: ScalaReflection.schemaFor[A12].dataType :: ScalaReflection.schemaFor[A13].dataType :: ScalaReflection.schemaFor[A14].dataType :: ScalaReflection.schemaFor[A15].dataType :: ScalaReflection.schemaFor[A16].dataType :: ScalaReflection.schemaFor[A17].dataType :: ScalaReflection.schemaFor[A18].dataType :: Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -365,9 +383,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag, A6: TypeTag, A7: TypeTag, A8: TypeTag, A9: TypeTag, A10: TypeTag, A11: TypeTag, A12: TypeTag, A13: TypeTag, A14: TypeTag, A15: TypeTag, A16: TypeTag, A17: TypeTag, A18: TypeTag, A19: TypeTag](name: String, func: Function19[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(ScalaReflection.schemaFor[A1].dataType :: ScalaReflection.schemaFor[A2].dataType :: ScalaReflection.schemaFor[A3].dataType :: ScalaReflection.schemaFor[A4].dataType :: ScalaReflection.schemaFor[A5].dataType :: ScalaReflection.schemaFor[A6].dataType :: ScalaReflection.schemaFor[A7].dataType :: ScalaReflection.schemaFor[A8].dataType :: ScalaReflection.schemaFor[A9].dataType :: ScalaReflection.schemaFor[A10].dataType :: ScalaReflection.schemaFor[A11].dataType :: ScalaReflection.schemaFor[A12].dataType :: ScalaReflection.schemaFor[A13].dataType :: ScalaReflection.schemaFor[A14].dataType :: ScalaReflection.schemaFor[A15].dataType :: ScalaReflection.schemaFor[A16].dataType :: ScalaReflection.schemaFor[A17].dataType :: ScalaReflection.schemaFor[A18].dataType :: ScalaReflection.schemaFor[A19].dataType :: Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -378,9 +396,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag, A6: TypeTag, A7: TypeTag, A8: TypeTag, A9: TypeTag, A10: TypeTag, A11: TypeTag, A12: TypeTag, A13: TypeTag, A14: TypeTag, A15: TypeTag, A16: TypeTag, A17: TypeTag, A18: TypeTag, A19: TypeTag, A20: TypeTag](name: String, func: Function20[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(ScalaReflection.schemaFor[A1].dataType :: ScalaReflection.schemaFor[A2].dataType :: ScalaReflection.schemaFor[A3].dataType :: ScalaReflection.schemaFor[A4].dataType :: ScalaReflection.schemaFor[A5].dataType :: ScalaReflection.schemaFor[A6].dataType :: ScalaReflection.schemaFor[A7].dataType :: ScalaReflection.schemaFor[A8].dataType :: ScalaReflection.schemaFor[A9].dataType :: ScalaReflection.schemaFor[A10].dataType :: ScalaReflection.schemaFor[A11].dataType :: ScalaReflection.schemaFor[A12].dataType :: ScalaReflection.schemaFor[A13].dataType :: ScalaReflection.schemaFor[A14].dataType :: ScalaReflection.schemaFor[A15].dataType :: ScalaReflection.schemaFor[A16].dataType :: ScalaReflection.schemaFor[A17].dataType :: ScalaReflection.schemaFor[A18].dataType :: ScalaReflection.schemaFor[A19].dataType :: ScalaReflection.schemaFor[A20].dataType :: Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -391,9 +409,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag, A6: TypeTag, A7: TypeTag, A8: TypeTag, A9: TypeTag, A10: TypeTag, A11: TypeTag, A12: TypeTag, A13: TypeTag, A14: TypeTag, A15: TypeTag, A16: TypeTag, A17: TypeTag, A18: TypeTag, A19: TypeTag, A20: TypeTag, A21: TypeTag](name: String, func: Function21[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(ScalaReflection.schemaFor[A1].dataType :: ScalaReflection.schemaFor[A2].dataType :: ScalaReflection.schemaFor[A3].dataType :: ScalaReflection.schemaFor[A4].dataType :: ScalaReflection.schemaFor[A5].dataType :: ScalaReflection.schemaFor[A6].dataType :: ScalaReflection.schemaFor[A7].dataType :: ScalaReflection.schemaFor[A8].dataType :: ScalaReflection.schemaFor[A9].dataType :: ScalaReflection.schemaFor[A10].dataType :: ScalaReflection.schemaFor[A11].dataType :: ScalaReflection.schemaFor[A12].dataType :: ScalaReflection.schemaFor[A13].dataType :: ScalaReflection.schemaFor[A14].dataType :: ScalaReflection.schemaFor[A15].dataType :: ScalaReflection.schemaFor[A16].dataType :: ScalaReflection.schemaFor[A17].dataType :: ScalaReflection.schemaFor[A18].dataType :: ScalaReflection.schemaFor[A19].dataType :: ScalaReflection.schemaFor[A20].dataType :: ScalaReflection.schemaFor[A21].dataType :: Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -404,9 +422,9 @@ class UDFRegistration private[sql] (sqlContext: SQLContext) extends Logging {
|
|
|
|
|
def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag, A6: TypeTag, A7: TypeTag, A8: TypeTag, A9: TypeTag, A10: TypeTag, A11: TypeTag, A12: TypeTag, A13: TypeTag, A14: TypeTag, A15: TypeTag, A16: TypeTag, A17: TypeTag, A18: TypeTag, A19: TypeTag, A20: TypeTag, A21: TypeTag, A22: TypeTag](name: String, func: Function22[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, RT]): UserDefinedFunction = {
|
|
|
|
|
val dataType = ScalaReflection.schemaFor[RT].dataType
|
|
|
|
|
val inputTypes = Try(ScalaReflection.schemaFor[A1].dataType :: ScalaReflection.schemaFor[A2].dataType :: ScalaReflection.schemaFor[A3].dataType :: ScalaReflection.schemaFor[A4].dataType :: ScalaReflection.schemaFor[A5].dataType :: ScalaReflection.schemaFor[A6].dataType :: ScalaReflection.schemaFor[A7].dataType :: ScalaReflection.schemaFor[A8].dataType :: ScalaReflection.schemaFor[A9].dataType :: ScalaReflection.schemaFor[A10].dataType :: ScalaReflection.schemaFor[A11].dataType :: ScalaReflection.schemaFor[A12].dataType :: ScalaReflection.schemaFor[A13].dataType :: ScalaReflection.schemaFor[A14].dataType :: ScalaReflection.schemaFor[A15].dataType :: ScalaReflection.schemaFor[A16].dataType :: ScalaReflection.schemaFor[A17].dataType :: ScalaReflection.schemaFor[A18].dataType :: ScalaReflection.schemaFor[A19].dataType :: ScalaReflection.schemaFor[A20].dataType :: ScalaReflection.schemaFor[A21].dataType :: ScalaReflection.schemaFor[A22].dataType :: Nil).getOrElse(Nil)
|
|
|
|
|
def builder(e: Seq[Expression]) = ScalaUDF(func, dataType, e, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, builder)
|
|
|
|
|
UserDefinedFunction(func, dataType)
|
|
|
|
|
val udf = UserDefinedFunction(func, dataType, inputTypes)
|
|
|
|
|
functionRegistry.registerFunction(name, udf.builder)
|
|
|
|
|
udf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|