You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "planga82 (via GitHub)" <gi...@apache.org> on 2023/02/01 15:01:31 UTC

[GitHub] [spark] planga82 commented on a diff in pull request #39826: [SPARK-42262][SQL] Table schema changes via V2SessionCatalog with HiveExternalCatalog

planga82 commented on code in PR #39826:
URL: https://github.com/apache/spark/pull/39826#discussion_r1093343828


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/V2SessionCatalog.scala:
##########
@@ -149,26 +150,42 @@ class V2SessionCatalog(catalog: SessionCatalog)
         throw QueryCompilationErrors.noSuchTableError(ident)
     }
 
-    val properties = CatalogV2Util.applyPropertiesChanges(catalogTable.properties, changes)
-    val schema = CatalogV2Util.applySchemaChanges(
-      catalogTable.schema, changes, catalogTable.provider, "ALTER TABLE")
-    val comment = properties.get(TableCatalog.PROP_COMMENT)
-    val owner = properties.getOrElse(TableCatalog.PROP_OWNER, catalogTable.owner)
-    val location = properties.get(TableCatalog.PROP_LOCATION).map(CatalogUtils.stringToURI)
-    val storage = if (location.isDefined) {
-      catalogTable.storage.copy(locationUri = location)
-    } else {
-      catalogTable.storage
+
+    val (columnChanges, otherChanges) = changes.toSeq.partition(change =>
+      change.isInstanceOf[ColumnChange] &&
+        // Not supported changes in alterTableDataSchema
+        !change.isInstanceOf[RenameColumn] && !change.isInstanceOf[DeleteColumn]
+    )
+
+    if(columnChanges.size > 0) {
+      val schema = CatalogV2Util.applySchemaChanges(
+        catalogTable.schema, changes, catalogTable.provider, "ALTER TABLE")

Review Comment:
   yes, you are right, in this case it would work because only one of the lists would have elements, but it is not correct



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org