AngersZhuuuu opened a new pull request, #36919:
URL: https://github.com/apache/spark/pull/36919
### What changes were proposed in this pull request?
For a simple case of RenameTable
```
test("rename a table") {
sql("ALTER TABLE h2.test.empty_table RENAME TO h2.test.empty_table2")
checkAnswer(
sql("SHOW TABLES IN h2.test"),
Seq(Row("test", "empty_table2")))
}
```
It will throw exception as below
```
[info] - rename a table *** FAILED *** (2 seconds, 358 milliseconds)
[info] org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException:
Failed table renaming from test.empty_table to h2.test.empty_table2
[info] at
org.apache.spark.sql.jdbc.H2Dialect$.classifyException(H2Dialect.scala:117)
[info] at
org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$.classifyException(JdbcUtils.scala:1176)
[info] at
org.apache.spark.sql.execution.datasources.v2.jdbc.JDBCTableCatalog.$anonfun$renameTable$1(JDBCTableCatalog.scala:102)
[info] at
org.apache.spark.sql.execution.datasources.v2.jdbc.JDBCTableCatalog.$anonfun$renameTable$1$adapted(JDBCTableCatalog.scala:100)
[info] at
org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$.withConnection(JdbcUtils.scala:1184)
[info] at
org.apache.spark.sql.execution.datasources.v2.jdbc.JDBCTableCatalog.renameTable(JDBCTableCatalog.scala:100)
[info] at
org.apache.spark.sql.execution.datasources.v2.RenameTableExec.run(RenameTableExec.scala:51)
[info] at
org.apache.spark.sql.execution.datasources.v2.V2CommandExec.result$lzycompute(V2CommandExec.scala:43)
[info] at
org.apache.spark.sql.execution.datasources.v2.V2CommandExec.result(V2CommandExec.scala:43)
[info] at
org.apache.spark.sql.execution.datasources.v2.V2CommandExec.executeCollect(V2CommandExec.scala:49)
[info] at
org.apache.spark.sql.execution.QueryExecution$$anonfun$eagerlyExecuteCommands$1.$anonfun$applyOrElse$1(QueryExecution.scala:98)
[info] at
org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$6(SQLExecution.scala:111)
[info] at
org.apache.spark.sql.execution.SQLExecution$.withSQLConfPropagated(SQLExecution.scala:171)
[info] at
org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$1(SQLExecution.scala:95)
[info] at
org.apache.spark.sql.SparkSession.withActive(SparkSession.scala:779)
[info] at
org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:64)
```
From here we pass all identifiers to the backend catalog with catalog, it
will failed the query.
In this pr we do below things:
1. Make sure that RENAME TABLE 's new table should bring catalog identifier
too.
2. Check catalog is same as old table ident
### Why are the changes needed?
Fix bugs. RENAME TABLE 's newTable and oldTable in V2 should both bring
catalog.
### Does this PR introduce _any_ user-facing change?
When people want to use RENAME TABLE in v2, should bring catalog info for
new ident too.
### How was this patch tested?
Added UT
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]