yadavay-amzn commented on code in PR #56472:
URL: https://github.com/apache/spark/pull/56472#discussion_r3422945485


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveTableSpec.scala:
##########
@@ -95,6 +95,18 @@ object ResolveTableSpec extends Rule[LogicalPlan] {
               messageParameters = Map("checkCondition" -> check.condition)
             )
           }
+          // Spark currently only supports session/temporary SQL variables
+          // (TempVariableManager); every VariableReference is therefore 
session-scoped and
+          // invalid in a persisted CHECK constraint. If persistent SQL 
variables are added
+          // later, tighten this to fire only on session-scoped variables.
+          check.child.foreach {
+            case v: VariableReference =>
+              throw QueryCompilationErrors
+                .notAllowedToCreateCheckConstraintReferencingTempVarError(
+                  Option(check.userProvidedName).getOrElse(""),

Review Comment:
   confirmed both `userProvidedName` and `tableName` are null at this point on 
the CREATE path with no name-synthesis helper available, so "" is the only safe 
value. 
   Kept it and added a short comment noting the empty name is intentional, as 
you suggested.



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