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


   ### What changes were proposed in this pull request?
   Use `LookupCatalog.AsTableIdentifier` in `ResolveSessionCatalog` to 
recognize `spark_catalog` and cut it off from new table/view identifier before 
passing it to `AlterTableRenameCommand`.
   
   ### Why are the changes needed?
   1. Other v1 commands recognize `spark_catalog` in table names. The table 
renaming command should recognize it for consistency.
   2. To be able to write unified tests for the v1 and v2 table renaming 
command.
   
   ### Does this PR introduce _any_ user-facing change?
   Yes.
   
   Before:
   ```sql
   spark-sql> CREATE TABLE spark_catalog.db.tbl (c0 INT) USING parquet;
   spark-sql> INSERT INTO spark_catalog.db.tbl SELECT 0;
   spark-sql> SELECT * FROM spark_catalog.db.tbl;
   0
   spark-sql> ALTER TABLE spark_catalog.db.tbl RENAME TO spark_catalog.db.tbl2;
   Error in query: spark_catalog.db.tbl2 is not a valid TableIdentifier as it 
has more than 2 name parts.
   ```
   
   After:
   ```sql
   spark-sql> ALTER TABLE spark_catalog.db.tbl RENAME TO spark_catalog.db.tbl2;
   spark-sql> SELECT * FROM spark_catalog.db.tbl2;
   0
   ```
   
   ### How was this patch tested?
   By running new test:
   ```
   $ build/sbt -Phive-2.3 -Phive-thriftserver "test:testOnly *CatalogedDDLSuite"
   ```


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