Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-19128

Refresh Metadata Cache After ALTER TABLE SET LOCATION

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Not A Problem
    • Affects Version/s: 2.1.0
    • Fix Version/s: None
    • Component/s: SQL
    • Labels:

      Description

      ALTER TABLE SET LOCATION is missing refresh table cache.

            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 codes still output the contents of the previous location after changing location.

        Attachments

          Activity

            People

            • Assignee:
              smilegator Xiao Li
              Reporter:
              smilegator Xiao Li
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: