danny0405 commented on code in PR #19733:
URL: https://github.com/apache/hudi/pull/19733#discussion_r3870038116
##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/hudi/command/AlterTableCommand.scala:
##########
@@ -208,10 +211,98 @@ case class AlterTableCommand(table: CatalogTable,
changes: Seq[TableChange], cha
val newTable = table.copy(
properties = table.properties ++ properties,
comment =
properties.get(TableCatalog.PROP_COMMENT).orElse(table.comment))
+ updateHoodieTableConfigs(sparkSession, properties)
catalog.alterTable(newTable)
logInfo("table properties change finished")
}
+ /**
+ * Persists Hudi table properties in hoodie.properties as well as the Spark
catalog.
+ *
+ * The analyzer only creates this command for Hudi V2 tables, so the table
is known to be a Hudi
+ * table. Keep non-Hudi properties catalog-only, matching Spark's normal
ALTER TABLE behavior.
+ * Hudi's SQL aliases and datasource options are converted to the canonical
keys stored in
+ * hoodie.properties before validation and persistence.
+ */
+ private val protectedTableConfigs = Set(
+ HoodieTableConfig.NAME.key,
+ HoodieTableConfig.TYPE.key,
+ HoodieTableConfig.VERSION.key,
+ HoodieTableConfig.INITIAL_VERSION.key,
+ HoodieTableConfig.PRECOMBINE_FIELD.key,
+ HoodieTableConfig.LOG_FILE_FORMAT.key,
+ HoodieTableConfig.RECORDKEY_FIELDS.key,
+ HoodieTableConfig.PARTITION_FIELDS.key,
+ HoodieTableConfig.ORDERING_FIELDS.key,
+ HoodieTableConfig.KEY_GENERATOR_CLASS_NAME.key,
+ HoodieTableConfig.KEY_GENERATOR_TYPE.key,
+ HoodieTableConfig.RECORD_MERGE_MODE.key,
+ HoodieTableConfig.RECORD_MERGE_STRATEGY_ID.key,
+ HoodieTableConfig.PAYLOAD_CLASS_NAME.key,
+ HoodieTableConfig.LEGACY_PAYLOAD_CLASS_NAME.key,
+ HoodieTableConfig.TABLE_CHECKSUM.key,
+ HoodieTableConfig.CREATE_SCHEMA.key,
+ HoodieTableConfig.POPULATE_META_FIELDS.key,
+ HoodieTableConfig.META_FIELDS_MODE.key,
+ HoodieTableConfig.BOOTSTRAP_BASE_PATH.key,
+ HoodieTableConfig.DATABASE_NAME.key,
+ HoodieTableConfig.TIMELINE_LAYOUT_VERSION.key,
Review Comment:
**[P1] Protect the physical timeline paths**
This immutable-config set includes the timeline layout version but omits
`HoodieTableConfig.TIMELINE_PATH` and `TIMELINE_HISTORY_PATH`. Both keys pass
`extractHoodieOptions`, so setting `hoodie.timeline.path` to another directory
rewrites `hoodie.properties`. Every newly constructed `HoodieTableMetaClient`
derives its timeline location from that property, so it will point away from
the existing instants and the table can appear to have no history; UNSET
similarly breaks a table that legitimately uses a custom path by reverting it
to the default. These structural paths need the same protection, or the
implementation should use an explicit allowlist of mutable properties.
--
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]