vladanvasi-db commented on code in PR #59959:
URL: https://github.com/apache/spark/pull/59959#discussion_r4455213338


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala:
##########
@@ -1922,6 +1922,34 @@ class AnalysisSuite extends AnalysisTest with Matchers {
     }
   }
 
+  test("collect temporary variables from expression roots, subqueries and plan 
children") {
+    def variable(name: String): VariableReference = {
+      val identifier = Identifier.of(Array("session"), name)
+      VariableReference(
+        originalNameParts = Seq("session", name),
+        catalog = FakeSystemCatalog,
+        identifier = identifier,
+        varDef = VariableDefinition(identifier, "1", Literal(1)))
+    }
+
+    val first = variable("first")
+    val second = variable("second")
+    val subqueryPlan = Project(Seq(Alias(Add(second, first), "value")()), 
OneRowRelation())
+    val subquery = ScalarSubquery(subqueryPlan)
+    val expression = Add(first, subquery)
+    val plan = Project(Seq(Alias(expression, "value")()), subqueryPlan)

Review Comment:
   Addressed in the verified local follow-up (not yet pushed): the child plan 
now contains a third variable that is absent from the root expression and its 
scalar subquery, and the plan assertion expects all three names. A root-only 
plan collector would miss the third variable and fail this assertion. The 
focused AnalysisSuite test passes. Production traversal is unchanged.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/IdentifierResolution.scala:
##########
@@ -48,4 +49,20 @@ object IdentifierResolution extends AliasHelper with 
EvalHelper {
         }
     }
   }
+
+  /** Collects distinct session variable names from a plan, including its 
subqueries. */

Review Comment:
   Addressed in the verified local follow-up (not yet pushed): both collector 
Scaladocs now describe distinct original name parts of session and SQL-script 
local variable references. The collection logic is unchanged.



##########
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ViewCommandHelper.scala:
##########
@@ -61,6 +61,34 @@ object ViewCommandHelper {
       dropView
   }
 
+  /**
+   * Lowers a session-catalog [[CreateView]] to [[CreateViewCommand]], leaving 
other targets intact.

Review Comment:
   Addressed in the verified local follow-up (not yet pushed): the CREATE VIEW 
helper Scaladoc now documents the existing failure when a session-catalog 
namespace does not contain exactly one part, matching the DROP VIEW helper. No 
error handling or runtime behavior changes.



-- 
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]

Reply via email to