-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-32401][SQL] Migrate function related commands to use UnresolvedFunc to resolve function identifier #29198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
Outdated
Show resolved
Hide resolved
|
Test build #126377 has finished for PR 29198 at commit
|
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
Show resolved
Hide resolved
| val pattern = Option(ctx.pattern).map(string(_)) | ||
| val functionName = Option(ctx.multipartIdentifier).map(visitMultipartIdentifier) | ||
| ShowFunctionsStatement(userScope, systemScope, pattern, functionName) | ||
| val functionName = Option(ctx.multipartIdentifier) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe unresolvedFunc? it's not a name anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or keep it functionName, and do
ShowFunctions(UnresolvedFunc(functionName), userScope, systemScope, pattern)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it to unresolvedFuncOpt since functionName in the second suggestion will be Option[Seq[String]].
| } | ||
|
|
||
| CreateFunction( | ||
| func, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how to deal with CREATE commands yet. For now, CREATE TABLE and VIEW still use statement plans. We don't need to do lookup for CREATE commands, so UnresolvedFunnc looks weird here.
Can we keep it unchanged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Will revert this change.
|
Test build #126511 has finished for PR 29198 at commit
|
viirya
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to briefly describe "the new resolution framework" so the reviewers can look at this quickly?
| } | ||
|
|
||
| case _ => throw new AnalysisException(s"$sql is only supported in v1 catalog") | ||
| case _ => throw new AnalysisException("function is only supported in v1 catalog") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function -> function command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is called from Analyzer.scala except for CREATE FUNCTION, so I thought more general name would be better here. But if you think function command is better here, I am happy to change it. Please let me know!
Updated. |
| userScope: Boolean, | ||
| systemScope: Boolean, | ||
| pattern: Option[String]) extends Command { | ||
| override def children: Seq[LogicalPlan] = if (child.isDefined) { child.get :: Nil } else { Nil } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: child.toSeq
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
| DropFunctionStatement( | ||
| functionName, | ||
| DropFunction( | ||
| UnresolvedFunc(functionName), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will analyzer give a nice error if UnresolvedFunc is left to CheckAnalysis?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm, this won't happen for now.
|
The PR itself LGTM. @viirya the new framework is to resolve SQL objects (table, view, function, etc.) in the analyzer, not at runtime in |
|
Test build #126725 has finished for PR 29198 at commit
|
|
thanks, merging to master! |
What changes were proposed in this pull request?
This PR proposes to migrate the following function related commands to use
UnresolvedFuncto resolve function identifier:DropFunctionStatement,DescribeFunctionStatementandShowFunctionsStatementlogical plans are replaced withDropFunction,DescribeFunctionandShowFunctionslogical plans respectively, and each containsUnresolvedFuncas its child so that it can be resolved inAnalyzer.Why are the changes needed?
Migrating to the new resolution framework, which resolves
UnresolvedFuncinAnalyzer.Does this PR introduce any user-facing change?
The message of exception thrown when a catalog is resolved to v2 has been merged to:
function is only supported in v1 catalogPreviously, it printed out the command used. E.g.,:
CREATE FUNCTION is only supported in v1 catalogHow was this patch tested?
Updated existing tests.