MaxGekk opened a new pull request #31229:
URL: https://github.com/apache/spark/pull/31229


   ### What changes were proposed in this pull request?
   Clear table cache after adding partitions to v2 table in 
`AlterTableAddPartitionExec`.
   
   ### Why are the changes needed?
   This PR fixes correctness issue. Without the fix, queries on cached tables 
modified via `ALTER TABLE .. ADD PARTITION` return incorrect results.
   
   ### Does this PR introduce _any_ user-facing change?
   Yes.
   
   ### How was this patch tested?
   By performing the following steps:
   1. Apply the change from the PR https://github.com/apache/spark/pull/31216
   2. Add the test below:
   ```scala
     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)))
       }
     }
   ```
   to `org.apache.spark.sql.execution.command.v2.AlterTableAddPartitionSuite`
   3. Run the unified tests for `ALTER TABLE .. ADD PARTITION`:
   ```
   $ build/sbt -Phive-2.3 -Phive-thriftserver "test:testOnly 
*.AlterTableAddPartitionSuite"
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



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

Reply via email to