szehon-ho commented on code in PR #51007: URL: https://github.com/apache/spark/pull/51007#discussion_r2110361072
########## sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/V2SessionCatalog.scala: ########## @@ -302,10 +302,22 @@ class V2SessionCatalog(catalog: SessionCatalog) val finalProperties = CatalogV2Util.applyClusterByChanges(properties, schema, changes) try { - catalog.alterTable( - catalogTable.copy( - properties = finalProperties, schema = schema, owner = owner, comment = comment, - collation = collation, storage = storage)) + if (SQLConf.get.getConf(StaticSQLConf.CATALOG_IMPLEMENTATION).equals("hive")) { Review Comment: let me check if it breaks tests... i thought InMemoryCatalog was used as default when you download spark, so didnt want to surprise users. ########## sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala: ########## @@ -3392,4 +3397,180 @@ class HiveDDLSuite ) } } + + test("SPARK-52272: V2SessionCatalog does not alter schema on Hive Catalog") { + val externalCatalog = new CustomHiveCatalog(spark.sessionState.catalog.externalCatalog) Review Comment: yea sorry it was late :), i rewrote it using mockito ########## sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/V2SessionCatalog.scala: ########## @@ -302,10 +302,22 @@ class V2SessionCatalog(catalog: SessionCatalog) val finalProperties = CatalogV2Util.applyClusterByChanges(properties, schema, changes) try { - catalog.alterTable( - catalogTable.copy( - properties = finalProperties, schema = schema, owner = owner, comment = comment, - collation = collation, storage = storage)) + if (SQLConf.get.getConf(StaticSQLConf.CATALOG_IMPLEMENTATION).equals("hive")) { + if (changes.exists(!_.isInstanceOf[TableChange.ColumnChange])) { + catalog.alterTable( + catalogTable.copy( + properties = finalProperties, schema = schema, owner = owner, comment = comment, + collation = collation, storage = storage)) + } + if (changes.exists(_.isInstanceOf[TableChange.ColumnChange])) { Review Comment: hm, yea i think this code does call both, if both exist? -- 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-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org