[
https://issues.apache.org/jira/browse/FLINK-41561?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sergey Nuyanzin resolved FLINK-41561.
-------------------------------------
Fix Version/s: 2.5.0
Resolution: Fixed
> CREATE VIEW and ALTER VIEW accept recursive view definitions
> ------------------------------------------------------------
>
> Key: FLINK-41561
> URL: https://issues.apache.org/jira/browse/FLINK-41561
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / Planner
> Reporter: Moritz Manner
> Assignee: Moritz Manner
> Priority: Major
> Labels: pull-request-available
> Fix For: 2.5.0
>
>
> {{CREATE VIEW}} and {{ALTER VIEW ... AS}} accept a query that leads back to
> the defined view, either directly or through other views. The statement
> succeeds and the stored view references itself. Every later query on the view
> fails during view expansion.
> Code to reproduce:
> {code:sql}
> CREATE TABLE t (a INT) WITH ('connector' = 'datagen');
> CREATE VIEW v AS SELECT * FROM t;
> ALTER VIEW v AS SELECT * FROM v; –- succeeds
> SELECT * FROM v; –- fails
> {code}
> The same happens through other views:
> {code:sql}
> CREATE VIEW v1 AS SELECT * FROM t;
> CREATE VIEW v2 AS SELECT * FROM v1;
> ALTER VIEW v1 AS SELECT * FROM v2; – succeeds, v1 -> v2 -> v1
> {code}
> And with a temporary view that hides the permanent view it reads from:
> {code:sql}
> CREATE VIEW v AS SELECT * FROM t;
> CREATE TEMPORARY VIEW v AS SELECT * FROM v; – succeeds
> {code}
> The query fails because the planner expands the view again and again.
> Depending on where it breaks, the user gets “SQL parse failed.” or an
> OutOfMemoryError after several minutes. Neither points to the actual problem.
> {{ALTER VIEW}} accepts the query because it is validated while the view still
> has its old definition. So {{SELECT * FROM v}} resolves against the old v and
> passes. The stored expanded query then points to v itself.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)