[GitHub] [spark] imback82 commented on a change in pull request #29198: [SPARK-32401][SQL] Migrate function related commands to new resolution framework

2020-07-24 Thread GitBox


imback82 commented on a change in pull request #29198:
URL: https://github.com/apache/spark/pull/29198#discussion_r460225678



##
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
##
@@ -3650,12 +3652,24 @@ class AstBuilder(conf: SQLConf) extends 
SqlBaseBaseVisitor[AnyRef] with Logging
   }
 }
 
-val functionIdentifier = visitMultipartIdentifier(ctx.multipartIdentifier)
-CreateFunctionStatement(
-  functionIdentifier,
+val nameParts = visitMultipartIdentifier(ctx.multipartIdentifier)
+val isTemp = ctx.TEMPORARY != null
+val func: LogicalPlan = if (isTemp) {
+  import org.apache.spark.sql.connector.catalog.CatalogV2Implicits._
+  // temp func doesn't belong to any catalog and we shouldn't resolve 
catalog in the name.
+  if (nameParts.length > 2) {
+throw new AnalysisException(s"Unsupported function name 
'${nameParts.quoted}'")
+  }
+  ResolvedFunc(nameParts.asIdentifier)
+} else {
+  UnresolvedFunc(nameParts)
+}
+
+CreateFunction(
+  func,

Review comment:
   Ok. Will revert this change.





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:
us...@infra.apache.org



-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] imback82 commented on a change in pull request #29198: [SPARK-32401][SQL] Migrate function related commands to new resolution framework

2020-07-24 Thread GitBox


imback82 commented on a change in pull request #29198:
URL: https://github.com/apache/spark/pull/29198#discussion_r460223500



##
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
##
@@ -3610,8 +3610,10 @@ class AstBuilder(conf: SQLConf) extends 
SqlBaseBaseVisitor[AnyRef] with Logging
 case Some(x) => throw new ParseException(s"SHOW $x FUNCTIONS not 
supported", ctx)
 }
 val pattern = Option(ctx.pattern).map(string(_))
-val functionName = 
Option(ctx.multipartIdentifier).map(visitMultipartIdentifier)
-ShowFunctionsStatement(userScope, systemScope, pattern, functionName)
+val functionName = Option(ctx.multipartIdentifier)

Review comment:
   Changed it to `unresolvedFuncOpt` since `functionName` in the second 
suggestion will be `Option[Seq[String]]`.





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:
us...@infra.apache.org



-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] imback82 commented on a change in pull request #29198: [SPARK-32401][SQL] Migrate function related commands to new resolution framework

2020-07-24 Thread GitBox


imback82 commented on a change in pull request #29198:
URL: https://github.com/apache/spark/pull/29198#discussion_r460223500



##
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
##
@@ -3610,8 +3610,10 @@ class AstBuilder(conf: SQLConf) extends 
SqlBaseBaseVisitor[AnyRef] with Logging
 case Some(x) => throw new ParseException(s"SHOW $x FUNCTIONS not 
supported", ctx)
 }
 val pattern = Option(ctx.pattern).map(string(_))
-val functionName = 
Option(ctx.multipartIdentifier).map(visitMultipartIdentifier)
-ShowFunctionsStatement(userScope, systemScope, pattern, functionName)
+val functionName = Option(ctx.multipartIdentifier)

Review comment:
   Changed it to `unresolvedFunc` since `functionName` in the second 
suggestion will be `Option[Seq[String]]`.





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:
us...@infra.apache.org



-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] imback82 commented on a change in pull request #29198: [SPARK-32401][SQL] Migrate function related commands to new resolution framework

2020-07-24 Thread GitBox


imback82 commented on a change in pull request #29198:
URL: https://github.com/apache/spark/pull/29198#discussion_r460222764



##
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##
@@ -1894,7 +1894,7 @@ class Analyzer(
 def apply(plan: LogicalPlan): LogicalPlan = plan.resolveOperatorsUp {
   // Resolve functions with concrete relations from v2 catalog.
   case UnresolvedFunc(multipartIdent) =>
-val funcIdent = parseSessionCatalogFunctionIdentifier(multipartIdent, 
"function lookup")
+val funcIdent = parseSessionCatalogFunctionIdentifier(multipartIdent)

Review comment:
   This will be used by `CREATE FUNCTION` when I revert the change.





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:
us...@infra.apache.org



-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] imback82 commented on a change in pull request #29198: [SPARK-32401][SQL] Migrate function related commands to new resolution framework

2020-07-22 Thread GitBox


imback82 commented on a change in pull request #29198:
URL: https://github.com/apache/spark/pull/29198#discussion_r459204665



##
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
##
@@ -3650,12 +3652,24 @@ class AstBuilder(conf: SQLConf) extends 
SqlBaseBaseVisitor[AnyRef] with Logging
   }
 }
 
-val functionIdentifier = visitMultipartIdentifier(ctx.multipartIdentifier)
-CreateFunctionStatement(
-  functionIdentifier,
+val nameParts = visitMultipartIdentifier(ctx.multipartIdentifier)
+val isTemp = ctx.TEMPORARY != null
+val func: LogicalPlan = if (isTemp) {
+  import org.apache.spark.sql.connector.catalog.CatalogV2Implicits._
+  // temp func doesn't belong to any catalog and we shouldn't resolve 
catalog in the name.
+  if (nameParts.length > 2) {
+throw new AnalysisException(s"Unsupported function name 
'${nameParts.quoted}'")
+  }
+  ResolvedFunc(nameParts.asIdentifier)

Review comment:
   This logic is moved from `ResolveSessionCatalog`, and I think we can 
resolve here directly.





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:
us...@infra.apache.org



-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org