GitHub user gatorsmile opened a pull request:

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

    [SPARK-22488] [SQL] Fix the view resolution issue in the SparkSession 
internal table() API 

    ## What changes were proposed in this pull request?
    The current internal `table()` API of `SparkSession` bypasses the Analyzer 
and directly calls `sessionState.catalog.lookupRelation` API. This skips the 
view resolution logics in our Analyzer rule `ResolveRelations`. This internal 
API is widely used by various DDL commands or the other internal APIs.
    
    Users might get the strange error caused by view resolution when the 
default database is different.
    ```
    Table or view not found: t1; line 1 pos 14
    org.apache.spark.sql.AnalysisException: Table or view not found: t1; line 1 
pos 14
        at 
org.apache.spark.sql.catalyst.analysis.package$AnalysisErrorAt.failAnalysis(package.scala:42)
    ```
    
    This PR is to fix it by enforcing it to use `ResolveRelations` to resolve 
the table.
    
    ## How was this patch tested?
    Added a test case and modified the existing test cases

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

    $ git pull https://github.com/gatorsmile/spark viewResolution

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

    https://github.com/apache/spark/pull/19713.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 #19713
    
----
commit d87f33327b351cea493a065d144044cf2c1a069f
Author: gatorsmile <gatorsm...@gmail.com>
Date:   2017-11-10T03:47:59Z

    fix.

----


---

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

Reply via email to