lunar-shadow commented on code in PR #55547:
URL: https://github.com/apache/spark/pull/55547#discussion_r3152967915


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala:
##########
@@ -448,14 +448,32 @@ class DataSourceV2Strategy(session: SparkSession) extends 
Strategy with Predicat
     case _: NoopCommand =>
       LocalTableScanExec(Nil, Nil, None) :: Nil
 
-    case RenameTable(r @ ResolvedTable(catalog, oldIdent, _, _), newIdent, 
isView) =>
+    case RenameTable(r @ ResolvedTable(catalog, oldIdent, _, _), 
rawNewNameParts, isView) =>
       if (isView) {
         throw QueryCompilationErrors.cannotRenameTableWithAlterViewError()
       }
+
+      // Strip catalog prefix if the identifier is catalog-qualified.
+      val newNameParts =
+        if (rawNewNameParts.length > 1 && rawNewNameParts.head == 
catalog.name()) {

Review Comment:
   Thanks @dongjoon-hyun for catching this. 
   
   Fixed, now using `SQLConf.get.resolver` for case-insensitive comparison. 
Added a test case: `ALTER TABLE testcat.ns.t1_renamed RENAME TO TesTcaT.ns.t1` 



##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala:
##########
@@ -448,14 +448,32 @@ class DataSourceV2Strategy(session: SparkSession) extends 
Strategy with Predicat
     case _: NoopCommand =>
       LocalTableScanExec(Nil, Nil, None) :: Nil
 
-    case RenameTable(r @ ResolvedTable(catalog, oldIdent, _, _), newIdent, 
isView) =>
+    case RenameTable(r @ ResolvedTable(catalog, oldIdent, _, _), 
rawNewNameParts, isView) =>
       if (isView) {
         throw QueryCompilationErrors.cannotRenameTableWithAlterViewError()
       }
+
+      // Strip catalog prefix if the identifier is catalog-qualified.
+      val newNameParts =
+        if (rawNewNameParts.length > 1 && rawNewNameParts.head == 
catalog.name()) {
+          rawNewNameParts.tail
+        } else {
+          rawNewNameParts
+        }
+
+      val namespace =
+        if (newNameParts.length == 1) {

Review Comment:
   Fixed, thanks.



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

Reply via email to