maropu commented on a change in pull request #28840:
URL: https://github.com/apache/spark/pull/28840#discussion_r442590610
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/connector/catalog/LookupCatalog.scala
##########
@@ -155,4 +155,37 @@ private[sql] trait LookupCatalog extends Logging {
None
}
}
+
+ /**
+ * Extract catalog and function identifier from a multi-part name with the
current catalog if
+ * needed.
+ *
+ * Note that: function is only supported in v1 catalog.
Review comment:
Still not sure about what this means... Could you describe more?
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala
##########
@@ -1341,6 +1341,16 @@ class SessionCatalog(
functionRegistry.registerFunction(func, info, builder)
}
+ /**
+ * Unregister a temporary or permanent function from a session-specific
[[FunctionRegistry]]
+ */
+ def unregisterFunction(name: FunctionIdentifier, ignoreIfNotExists:
Boolean): Unit = {
Review comment:
`ignoreIfNotExists` not used now?
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/connector/catalog/LookupCatalog.scala
##########
@@ -155,4 +155,37 @@ private[sql] trait LookupCatalog extends Logging {
None
}
}
+
+ /**
+ * Extract catalog and function identifier from a multi-part name with the
current catalog if
+ * needed.
+ *
+ * Note that: function is only supported in v1 catalog.
+ */
+ object CatalogAndFunctionIdentifier {
Review comment:
Have you checked my comment?
https://github.com/apache/spark/pull/28840/files#r442021563 I personally think
you don't need this refactoring. Could you just use
`parseSessionCatalogFunctionIdentifier` in this PR?
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/connector/catalog/LookupCatalog.scala
##########
@@ -155,4 +155,37 @@ private[sql] trait LookupCatalog extends Logging {
None
}
}
+
+ /**
+ * Extract catalog and function identifier from a multi-part name with the
current catalog if
+ * needed.
+ *
+ * Note that: function is only supported in v1 catalog.
+ */
+ object CatalogAndFunctionIdentifier {
+ def unapply(nameParts: Seq[String]): Option[(CatalogPlugin,
FunctionIdentifier)] = {
+
+ if (nameParts.length == 1 &&
catalogManager.v1SessionCatalog.isTempFunction(nameParts.head)) {
+ return Some(currentCatalog, FunctionIdentifier(nameParts.head))
+ }
+
+ nameParts match {
+ case SessionCatalogAndIdentifier(catalog, ident) =>
+ if (nameParts.length == 1) {
+ // If there is only one name part, it means the current catalog is
the session catalog.
+ // Here we don't fill the default database, to keep the error
message unchanged for
+ // v1 commands.
+ Some(catalog, FunctionIdentifier(nameParts.head, None))
+ } else {
+ ident.namespace match {
+ case Array(db) => Some(catalog, FunctionIdentifier(ident.name,
Some(db)))
+ case _ =>
+ throw new AnalysisException(s"Unsupported function name
'$ident'")
+ }
+ }
+
+ case _ => throw new AnalysisException("Function command is only
supported in v1 catalog")
Review comment:
What's `Function command`?
----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]