imback82 commented on a change in pull request #30856:
URL: https://github.com/apache/spark/pull/30856#discussion_r546273904
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/RenameTableExec.scala
##########
@@ -17,24 +17,41 @@
package org.apache.spark.sql.execution.datasources.v2
+import org.apache.spark.sql.{DataFrame, Dataset}
import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.expressions.Attribute
import org.apache.spark.sql.connector.catalog.{Identifier, TableCatalog}
+import org.apache.spark.storage.StorageLevel
/**
* Physical plan node for renaming a table.
*/
case class RenameTableExec(
catalog: TableCatalog,
oldIdent: Identifier,
- newIdent: Identifier) extends V2CommandExec {
+ newIdent: Identifier,
+ invalidateCache: () => Option[StorageLevel],
+ cacheTable: (DataFrame, Option[String], StorageLevel) => Unit)
+ extends V2CommandExec {
override def output: Seq[Attribute] = Seq.empty
override protected def run(): Seq[InternalRow] = {
+ import
org.apache.spark.sql.connector.catalog.CatalogV2Implicits.IdentifierHelper
+
+ val optOldStorageLevel = invalidateCache()
catalog.invalidateTable(oldIdent)
+
catalog.renameTable(oldIdent, newIdent)
+ optOldStorageLevel.foreach { oldStorageLevel =>
+ val tbl = catalog.loadTable(newIdent)
+ val newRelation = DataSourceV2Relation.create(tbl, Some(catalog),
Some(newIdent))
+ cacheTable(
+ Dataset.ofRows(sqlContext.sparkSession, newRelation),
Review comment:
This change is to work around the dependent PR: #30825.
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala
##########
@@ -268,7 +275,13 @@ class DataSourceV2Strategy(session: SparkSession) extends
Strategy with Predicat
AlterTableExec(catalog, ident, changes) :: Nil
case RenameTable(catalog, oldIdent, newIdent) =>
- RenameTableExec(catalog, oldIdent, newIdent) :: Nil
+ val tbl = ResolvedTable(catalog, oldIdent, catalog.loadTable(oldIdent))
Review comment:
This change is to work around #30610.
----------------------------------------------------------------
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]