Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-33507 Improve and fix cache behavior in v1 and v2
  3. SPARK-34149

DSv2: `ALTER TABLE .. ADD PARTITION` does not refresh table cache

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.2.0
    • 3.2.0
    • SQL
    • None

    Description

      For example, the test below:

        test("SPARK-XXXXX: refresh cache in partition adding") {
          withNamespaceAndTable("ns", "tbl") { t =>
            sql(s"CREATE TABLE $t (part int) $defaultUsing PARTITIONED BY (part)")
            sql(s"ALTER TABLE $t ADD PARTITION (part=0)")
            assert(!spark.catalog.isCached(t))
            sql(s"CACHE TABLE $t")
            assert(spark.catalog.isCached(t))
            checkAnswer(sql(s"SELECT * FROM $t"), Row(0))
      
            sql(s"ALTER TABLE $t ADD PARTITION (part=1)")
            assert(spark.catalog.isCached(t))
            checkAnswer(sql(s"SELECT * FROM $t"), Seq(Row(0), Row(1)))
          }
        }
      

      fails with;

      !== Correct Answer - 2 ==   == Spark Answer - 1 ==
      !struct<>                   struct<part:int>
       [0]                        [0]
      ![1]                        
          
             
      ScalaTestFailureLocation: org.apache.spark.sql.QueryTest$ at (QueryTest.scala:243)
      

      because the command doesn't refresh the cache.

      Attachments

        Issue Links

          Activity

            People

              maxgekk Max Gekk
              maxgekk Max Gekk
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: