GitHub user jiangxb1987 opened a pull request:

    https://github.com/apache/spark/pull/17152

    [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")`.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jiangxb1987/spark cyclic-view

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/17152.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #17152
    
----
commit 1bd02603fa24e6790994105cd47c8b55a4c1de40
Author: jiangxingbo <[email protected]>
Date:   2017-03-03T15:30:59Z

    detect cyclic view references.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to