JingsongLi commented on code in PR #1019:
URL: https://github.com/apache/paimon-rust/pull/1019#discussion_r4176868485
##########
crates/paimon/src/spec/schema.rs:
##########
@@ -584,6 +584,25 @@ impl TableSchema {
})?;
fields[idx] =
fields[idx].clone().with_description(Some(new_comment));
}
+ SchemaChange::UpdateColumnDefaultValue {
+ field_names,
+ new_default_value,
+ } => {
+ let name = top_level_field(&field_names)?;
+ let idx =
+ field_index(&fields, name).ok_or_else(||
crate::Error::ColumnNotExist {
+ full_name: full_name.to_string(),
+ column: name.to_string(),
+ })?;
+ // The default value is recorded on the field as a string
and is
+ // cast/validated where it is consumed (the read path),
exactly as
+ // a default set at create time; this arm only records the
new
+ // spelling. Mirrors Java `SchemaManager` rebuilding the
field with
+ // the new default value.
+ fields[idx] = fields[idx]
Review Comment:
[P2] Validate the new default before publishing the schema
A real FileSystemCatalog Format Table probe changes an INT default from 42
to bad: alter_table returns Ok and advances schema 1 to 2, but the next
new_write fails with Unsupported default value bad, even before input is
written. This handler lets an invalid configuration disable future writes. Java
[SchemaManagerUtils](https://github.com/apache/paimon/blob/master/paimon-core/src/main/java/org/apache/paimon/schema/SchemaManagerUtils.java)
calls validateDefaultValue(field.type(), update.newDefaultValue()) in this
branch before rebuilding the field. Validate against the column type before
applying/persisting the change so a rejected alteration leaves the previous
schema usable.
##########
crates/paimon/src/spec/schema_change.rs:
##########
@@ -80,6 +80,12 @@ pub enum SchemaChange {
field_names: Vec<String>,
new_comment: String,
},
+ /// A SchemaChange to update the field's default value.
+ #[serde(rename_all = "camelCase")]
+ UpdateColumnDefaultValue {
+ field_names: Vec<String>,
+ new_default_value: String,
Review Comment:
[P2] Support Java null defaults when clearing an existing default
The Java-compatible payload
{"action":"updateColumnDefaultValue","fieldNames":["v"],"newDefaultValue":null}
fails Rust deserialization with invalid type: null, expected a string. Java
[DefaultValueUtils](https://github.com/apache/paimon/blob/master/paimon-common/src/main/java/org/apache/paimon/utils/DefaultValueUtils.java)
accepts null, and its schema-change handler passes it to DataField, removing
the existing default. This String field and the unconditional Some in
apply_changes prevent that operation. Model the value as optional and preserve
None through application, with set/clear wire and catalog tests.
--
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]