maropu commented on a change in pull request #28840:
URL: https://github.com/apache/spark/pull/28840#discussion_r442020636
##########
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: now function is only supported in v1 catalog.
+ */
+ object CatalogAndFunctionIdentifier {
+ def unapply(nameParts: Seq[String]): Some[(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(s"Function command is only
supported in v1 catalog")
Review comment:
nit: drop `s` in the head.
----------------------------------------------------------------
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]