-
- Downloads
[SPARK-18389][SQL] Disallow cyclic view reference
## What changes were proposed in this pull request? Disallow cyclic view references, a cyclic view reference may be created by the following queries: ``` CREATE VIEW testView AS SELECT id FROM tbl CREATE VIEW testView2 AS SELECT id FROM testView ALTER VIEW testView AS SELECT * FROM testView2 ``` In the above example, a reference cycle (testView -> testView2 -> testView) exsits. We disallow cyclic view references by checking that in ALTER VIEW command, when the `analyzedPlan` contains the same `View` node with the altered view, we should prevent the behavior and throw an AnalysisException. ## How was this patch tested? Test by `SQLViewSuite.test("correctly handle a cyclic view reference")`. Author: jiangxingbo <jiangxb1987@gmail.com> Closes #17152 from jiangxb1987/cyclic-view.
Showing
- sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala 59 additions, 2 deletions.../scala/org/apache/spark/sql/execution/command/views.scala
- sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewSuite.scala 31 additions, 4 deletions...t/scala/org/apache/spark/sql/execution/SQLViewSuite.scala
Loading
Please register or sign in to comment