JingsongLi commented on code in PR #1447:
URL: https://github.com/apache/paimon-rust/pull/1447#discussion_r4609779774
##########
crates/paimon/src/spec/schema.rs:
##########
@@ -672,8 +672,7 @@ impl TableSchema {
),
});
}
- fields[idx] = DataField::new(old.id(),
old.name().to_string(), target)
- .with_description(old.description().map(|s|
s.to_string()));
+ fields[idx] = old.clone().with_data_type(target);
Review Comment:
Could we validate the existing default against `target` before publishing
the type change? On an empty Format Table, narrowing `BIGINT DEFAULT
2147483648` to `INT` succeeds here and keeps the out-of-range default. Every
subsequent `new_write()` then fails because `FormatTableWriter::new` parses all
defaults up front, even when the caller supplies a value for that column. A
regression test should assert that this ALTER fails and leaves the schema
version unchanged. [Java's type-change
validation](https://github.com/apache/paimon/blob/2bf10c194b9213e406b8cf0732b9e947f835cebd/paimon-core/src/main/java/org/apache/paimon/schema/SchemaManagerUtils.java#L353-L365)
##########
crates/paimon/src/spec/schema.rs:
##########
@@ -733,6 +732,8 @@ impl TableSchema {
new_schema.highest_field_id =
highest_field_id.max(Self::current_highest_field_id(&new_schema.fields));
+ super::generated_column::validate_evolution(&self.fields,
&new_schema.fields)?;
Review Comment:
Could we also enforce Java's generated-column constraints in
`Schema::validate_final_schema`, which covers both CREATE and ALTER? Adding a
`ROW` with a generated child to an ordinary table passes this top-level check.
Setting `rowkind.field` to an existing generated `STRING` column also passes
because the fields are unchanged. At creation time the builder likewise accepts
a column with both `defaultValue` and `generationExpression`. Java rejects all
three when it initializes the table store, so a successful Rust DDL can leave
Java readers and writers unable to use the table. These checks only need the
final fields and options. [Java schema
validation](https://github.com/apache/paimon/blob/2bf10c194b9213e406b8cf0732b9e947f835cebd/paimon-core/src/main/java/org/apache/paimon/schema/SchemaValidation.java#L1503-L1537)
ยท [Store
initialization](https://github.com/apache/paimon/blob/2bf10c194b9213e406b8cf0732b9e947f835cebd/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileSto
reTable.java#L370-L379)
--
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]