davidm-db commented on code in PR #47404:
URL: https://github.com/apache/spark/pull/47404#discussion_r1689261990
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala:
##########
@@ -133,12 +133,42 @@ class AstBuilder extends DataTypeAstBuilder with
SQLConfHelper with Logging {
private def visitCompoundBodyImpl(
ctx: CompoundBodyContext,
- label: Option[String]): CompoundBody = {
+ label: Option[String],
+ allowVarDeclare: Boolean): CompoundBody = {
val buff = ListBuffer[CompoundPlanStatement]()
ctx.compoundStatements.forEach(compoundStatement => {
buff += visit(compoundStatement).asInstanceOf[CompoundPlanStatement]
})
+ val compoundStatements = buff.toList
+
+ val candidates = if (allowVarDeclare) {
+ compoundStatements.dropWhile {
+ case SingleStatement(_: CreateVariable) => true
Review Comment:
Agreement with Serge is that we should be able to reference session
variables at all times using `system.session.<varName>`. Also, local variables
can be accessed by their name directly, but also using `<labelName>.<varName>`
to allow access to all local variables in case some of them have been shadowed.
Though, what I explained is a resolution part not the creation. For the
creation, looking at the code and documentation, we should allow the same thing
as well:
<img width="803" alt="image"
src="https://github.com/user-attachments/assets/8e77f0f0-e954-4ead-894b-3ff59c3a48a5">
I will check with Serge once again, just to confirm, but wouldn't block this
PR on it because we are preparing a POC for variables anyways which is supposed
to handle all local variable related stuff and we will resolve all such cases
there, if that's fine by you!
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]