GitHub user dongjoon-hyun opened a pull request:

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

    [SPARK-16771][SQL] WITH clause should not fall into infinite loop.

    ## What changes were proposed in this pull request?
    
    This PR changes the table resolving rule to use database tables before CTE 
tables in order to prevent infinite loops on CTE table name resolution.
    
    **Reported Error Scenarios**
    ```scala
    scala> spark.range(10).createOrReplaceTempView("t")
    scala> sql("WITH t AS (SELECT 1 FROM t) SELECT * FROM t")
    java.lang.StackOverflowError
    ...
    ```
    
    ```scala
    scala> spark.range(10).createOrReplaceTempView("t1")
    scala> spark.range(10).createOrReplaceTempView("t2")
    scala> sql("WITH t1 AS (SELECT 1 FROM t2), t2 AS (SELECT 1 FROM t1) SELECT 
* FROM t1, t2")
    java.lang.StackOverflowError
    ...
    ```
    
    
    ## How was this patch tested?
    
    Pass the Jenkins tests with new two testcases.

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

    $ git pull https://github.com/dongjoon-hyun/spark SPARK-16771-TREENODE

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

    https://github.com/apache/spark/pull/14397.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 #14397
    
----
commit 5bca528d971cad317f748cb3f2d050ce0b8f99a7
Author: Dongjoon Hyun <dongj...@apache.org>
Date:   2016-07-29T04:41:20Z

    [SPARK-16771][SQL] WITH clause should not fall into infinite loop.

----


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to