manner opened a new pull request, #30015:
URL: https://github.com/apache/flink/pull/30015
## What is the purpose of the change
`CREATE VIEW` and `ALTER VIEW ... AS` accept a query that leads back to the
defined view, either directly or through other views. For example, `ALTER VIEW
v AS SELECT * FROM v` validates the query against the old definition of `v` and
stores a view that references itself. Every later query on such a view expands
it again and again until it fails with "SQL parse failed." or runs out of
memory.
This pull request rejects such definitions with a clear error and gives the
same error for recursive views that are already stored in a catalog.
## Brief change log
- `FlinkPlannerImpl` tracks the views it is currently expanding. When it
reaches one of them again, it fails with a `ValidationException` that shows the
cycle, e.g. ``View `cat`.`db`.`v1` references itself: `cat`.`db`.`v1` ->
`cat`.`db`.`v2` -> `cat`.`db`.`v1`. Recursive views are not supported.``
- `CREATE [TEMPORARY] VIEW` and `ALTER VIEW ... AS` convert their query as
part of the expansion of the defined view, so a recursive definition is
rejected before it is stored. An altered view keeps its old definition.
## Verifying this change
This change added tests and can be verified as follows:
- Added `RecursiveViewTest`, which covers:
- `ALTER VIEW` that references the view directly and through other views,
including the error message and that the stored definition is unchanged
- `CREATE TEMPORARY VIEW` that hides the view it reads from
- a query on a recursive view that is stored in the catalog directly
- a view that reads the same view twice in one query, which must not be
rejected
- Without the fix, the tests for recursive views fail with "SQL parse
failed." or an `OutOfMemoryError`.
- Existing view tests pass, such as `CatalogViewITCase`,
`NestedViewResolutionTest` and `SqlDdlToOperationConverterTest`.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API, i.e., is any changed class annotated with
`@Public(Evolving)`: no
- The serializers: no
- The runtime per-record code paths (performance sensitive): no
- Anything that affects deployment or recovery: JobManager (and its
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
- The S3 file system connector: no
## Documentation
- Does this pull request introduce a new feature? no
- If yes, how is the feature documented? not applicable
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes (please specify the tool below)
Generated-by: Claude Code (Claude Opus 5.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]