You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/08/17 05:48:57 UTC
[GitHub] [spark] ulysses-you commented on a change in pull request #28840: [SPARK-31999][SQL] Add REFRESH FUNCTION command
ulysses-you commented on a change in pull request #28840:
URL: https://github.com/apache/spark/pull/28840#discussion_r471244264
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/command/functions.scala
##########
@@ -236,6 +236,45 @@ case class ShowFunctionsCommand(
}
}
+
+/**
+ * A command for users to refresh the persistent function.
+ * The syntax of using this command in SQL is:
+ * {{{
+ * REFRESH FUNCTION functionName
+ * }}}
+ */
+case class RefreshFunctionCommand(
+ databaseName: Option[String],
+ functionName: String)
+ extends RunnableCommand {
+
+ override def run(sparkSession: SparkSession): Seq[Row] = {
+ val catalog = sparkSession.sessionState.catalog
+ if (FunctionRegistry.builtin.functionExists(FunctionIdentifier(functionName))) {
Review comment:
It seems no meaning to refresh a persistent function whose name is same as a built-in function.
Yes, we can create a persistent function with the same name as the built-in function, but just create in metastore. The actual function we used is the built-in function. The reason is built-in functions are pre-cached in registry and we lookup cached function first.
e.g., `CREATE FUNCTION rand AS 'xxx'`, `DESC FUNCTION rand` will always return `Class: org.apache.spark.sql.catalyst.expressions.Rand`.
BTW, maybe it's the reason why we create function and load it lazy that just be a Hive client, otherwise we can't create such function like `rand`,`md5` in metastore. @cloud-fan
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org