manuzhang opened a new pull request, #58146:
URL: https://github.com/apache/spark/pull/58146
### What changes were proposed in this pull request?
Update `ViewHelper.checkCyclicViewReference` to traverse complete expression
trees when
looking for subquery expressions. Add a regression case where a scalar
subquery that
references the altered view is nested below an equality predicate.
### Why are the changes needed?
The current check only inspects top-level plan expressions. It detects an
`EXISTS`
subquery when the subquery is the expression root, but misses scalar and
other subqueries
nested inside larger expressions. A recursive view definition can therefore
be accepted
and fail later during view resolution with the maximum nested-view-depth
error.
### Does this PR introduce _any_ user-facing change?
Yes. `CREATE OR REPLACE VIEW` and `ALTER VIEW` now reject recursive
references from
subqueries nested inside larger expressions with `RECURSIVE_VIEW`, matching
root-level
subquery behavior.
### How was this patch tested?
Added a regression assertion to `SimpleSQLViewSuite` and ran:
```
SPARK_LOCAL_IP=127.0.0.1 build/sbt \
'sql/testOnly org.apache.spark.sql.execution.SimpleSQLViewSuite -- -z
"correctly handle a cyclic view reference"'
build/sbt 'sql/scalastyle' 'sql/Test/scalastyle'
```
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Codex (GPT-5)
--
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]