uros-b commented on code in PR #56472:
URL: https://github.com/apache/spark/pull/56472#discussion_r3443310236


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala:
##########
@@ -947,6 +947,21 @@ trait CheckAnalysis extends LookupCatalog with 
QueryErrorsBase with PlanToString
               messageParameters = Map("checkCondition" -> 
a.checkConstraint.condition)
             )
 
+          // Reject session/temp variables in persisted CHECK constraints.
+          case a: AddCheckConstraint =>
+            a.checkConstraint.child.collectFirst {
+              case v: VariableReference => v
+            }.foreach { v =>
+              v.failAnalysis(

Review Comment:
   Nit about code duplication: the ~13-line variable-detection block is 
copy-pasted into both ResolveTableSpec.scala (lines ~98-112) and 
CheckAnalysis.scala (lines ~950-962). Please consider using a shared helper 
(e.g. on CheckConstraint or a small util) to reduce drift risk if the 
message/logic ever 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