dongjoon-hyun commented on code in PR #49389:
URL: https://github.com/apache/spark/pull/49389#discussion_r1904924312
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala:
##########
@@ -1597,6 +1657,88 @@ class SessionCatalog(
"hive")
}
+ /**
+ * Registers a temporary or persistent SQL scalar function into a
session-specific
+ * [[FunctionRegistry]].
+ */
+ def registerSQLScalarFunction(
+ function: SQLFunction,
+ overrideIfExists: Boolean): Unit = {
+ registerUserDefinedFunction[Expression](
+ function,
+ overrideIfExists,
+ functionRegistry,
+ makeSQLFunctionBuilder(function))
+ }
+
+ /**
+ * Registers a temporary or persistent SQL table function into a
session-specific
+ * [[TableFunctionRegistry]].
+ */
+ def registerSQLTableFunction(
+ function: SQLFunction,
+ overrideIfExists: Boolean): Unit = {
+ registerUserDefinedFunction[LogicalPlan](
+ function,
+ overrideIfExists,
+ tableFunctionRegistry,
+ makeSQLTableFunctionBuilder(function))
+ }
+
+ /**
+ * Rearranges the arguments of a UDF into positional order.
+ */
+ private def rearrangeArguments(
+ inputParams: Option[StructType],
+ expressions: Seq[Expression],
+ functionName: String) : Seq[Expression] = {
+ val firstNamedArgumentExpressionIdx =
+ expressions.indexWhere(_.isInstanceOf[NamedArgumentExpression])
+ if (firstNamedArgumentExpressionIdx == -1) {
+ return expressions
+ }
+
+ if (!SQLConf.get.getConf(SQLConf.ALLOW_NAMED_FUNCTION_ARGUMENTS)) {
+ val firstNamedArgument = expressions(firstNamedArgumentExpressionIdx)
+ .asInstanceOf[NamedArgumentExpression].key
+ throw UserDefinedFunctionErrors.namedParametersNotSupportedForSqlUdfs(
+ functionName, firstNamedArgument)
+ }
+
+ val paramNames: Seq[InputParameter] =
+ if (inputParams.isDefined) {
+ inputParams.get.map {
+ p => p.getDefault() match {
+ case Some(defaultExpr) =>
+ // This cast is needed to ensure default value is of target data
type
Review Comment:
nit.
```
- to ensure default value is of target data type
- to ensure the default value is of the target data type
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]