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


   ### What changes were proposed in this pull request?
   1. Invoke `refreshTable()` from `AlterTableRenamePartitionCommand.run()` 
after partitions renaming. In particular, this re-creates the cache associated 
with the modified table.
   2. Refresh the cache associated with tables from v2 table catalogs in the 
`ALTER TABLE .. RENAME TO PARTITION` command.
   
   ### Why are the changes needed?
   This fixes the issues portrayed by the example:
   ```sql
   spark-sql> CREATE TABLE tbl1 (col0 int, part0 int) USING parquet PARTITIONED 
BY (part0);
   spark-sql> INSERT INTO tbl1 PARTITION (part0=0) SELECT 0;
   spark-sql> INSERT INTO tbl1 PARTITION (part0=1) SELECT 1;
   spark-sql> CACHE TABLE tbl1;
   spark-sql> SELECT * FROM tbl1;
   0    0
   1    1
   spark-sql> ALTER TABLE tbl1 PARTITION (part0=0) RENAME TO PARTITION (part=2);
   spark-sql> SELECT * FROM tbl1;
   0    0
   1    1
   ```
   The last query must not return `0    2` since `0  0` was renamed by previous 
command.
   
   ### Does this PR introduce _any_ user-facing change?
   Yes. After the changes for the example above:
   ```sql
   ...
   spark-sql> ALTER TABLE tbl1 PARTITION (part=0) RENAME TO PARTITION (part=2);
   spark-sql> SELECT * FROM tbl1;
   0    2
   1    1
   ```
   
   ### How was this patch tested?
   By running the affected test suite:
   ```
   $ build/sbt -Phive-2.3 -Phive-thriftserver "test:testOnly *CachedTableSuite"
   ```
   
   Authored-by: Max Gekk <[email protected]>
   Signed-off-by: HyukjinKwon <[email protected]>
   (cherry picked from commit b77d11dfd942ee2164dde2f5c25c6aaed65c444c)
   Signed-off-by: Max Gekk <[email protected]>


----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to