GitHub user gatorsmile opened a pull request:

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

    [SPARK-19128] [SQL] Refresh Cache after Set Location

    ### What changes were proposed in this pull request?
    ```Scala
          val catalog = spark.sessionState.catalog
          sql("CREATE TABLE tab1 using parquet AS SELECT 1 as a")
          sql("CREATE TABLE tab2 using parquet AS SELECT 2 as a")
          checkAnswer(spark.table("tab1"), Seq(Row(1)))
          checkAnswer(spark.table("tab2"), Seq(Row(2)))
          val metadataTab1 = catalog.getTableMetadata(TableIdentifier("tab1"))
          val locTab1 = metadataTab1.storage.locationUri
          sql(s"ALTER TABLE tab2 SET LOCATION '${locTab1.get}'")
          spark.table("tab2").show()
    ```
    The above example will output incorrect the results. The reason is the 
cached relation's location still points to the old location. 
    
    Thus, this PR is to refresh the cache after `SET LOCATION`.
    
    ### How was this patch tested?
    Added test cases into HiveDDLSuite.scala

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

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

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

    https://github.com/apache/spark/pull/16514.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 #16514
    
----
commit fa49848cee21a05c02466295a39d04fd73470687
Author: gatorsmile <gatorsm...@gmail.com>
Date:   2017-01-09T07:17:30Z

    fix.

----


---
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