yadavay-amzn commented on code in PR #56472:
URL: https://github.com/apache/spark/pull/56472#discussion_r3423146293
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala:
##########
@@ -947,6 +947,20 @@ trait CheckAnalysis extends LookupCatalog with
QueryErrorsBase with PlanToString
messageParameters = Map("checkCondition" ->
a.checkConstraint.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.
+ case a: AddCheckConstraint =>
+ a.checkConstraint.child.foreach {
+ case v: VariableReference =>
+ throw QueryCompilationErrors
Review Comment:
That's a good point. I switched both throws to `failAnalysis` on the
offending `VariableReference`, so the error now carries the query context and
points at the variable (e.g. `my_var`), consistent with the adjacent
`NON_DETERMINISTIC_CHECK_CONSTRAINT`. Updated the tests to assert the
`ExpectedContext`, and removed the now-unused `QueryCompilationErrors` helper.
--
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]