feat(catalog): support column-level alter table#370
Conversation
43cb777 to
8d214bf
Compare
|
Pushed a fix for the |
8d214bf to
44fa702
Compare
|
Cross-PR note with #340: if Right now the rename path rewrites This is not visible against current |
|
Thanks — confirmed. The rename path here only ports case 1 of Java's applyRenameColumnsToOptions (primary_keys / bucket-key / sequence.field); it doesn't rewrite the field-scoped fields..* keys (Java case 2: aggregate-function / ignore-retract / distinct / list-agg-delimiter, and case 3: sequence-group / nested-key). Worth noting this is already latent for partial-update tables on main, not only when composing with #340. To keep this PR scoped to the alter-table feature as reviewed, I'll track the field-scoped option rewriting as a follow-up: #383. |
Implement all column-level SchemaChange variants in TableSchema::apply_changes (add/rename/drop column, update column type/nullability/comment/position, update table comment), so FileSystemCatalog::alter_table and RESTCatalog::alter_table can evolve table schemas. Changes operate on top-level columns and reuse the existing ColumnAlreadyExist/ColumnNotExist errors; apply_changes keeps its single-argument signature (the catalog fills in the table name). Align the SchemaChange JSON wire format with Java Paimon: internally tagged by "action", with fieldNames arrays, comment / newDataType / keepNullability / newNullability / newComment fields, referenceFieldName move anchors, and FIRST/AFTER/BEFORE/LAST move types. Add AlterTableRequest and RESTApi::alter_table, and implement RESTCatalog::alter_table so the REST client can alter tables against a Paimon REST server.
Address review comments on column-level alter table: - AddColumn: reject NOT NULL types; reassign nested field IDs from the table-wide highest field ID (mirrors Java ReassignFieldId); make current_highest_field_id nested-aware - DropColumn: reject dropping the last field - UpdateColumnType: reject partition-key and primary-key columns - UpdateColumnNullability: reject making a primary-key column nullable - RenameColumn: reject partition columns; propagate renames into bucket-key and sequence.field options
…n alter UpdateColumnType now rejects conversions that are not supported Paimon casts (ported from Java DataTypeCasts implicit/explicit rules) or not executable by the arrow read path, honoring disable-explicit-type-casting. Type changes involving BLOB columns are rejected, and converting nullable columns to NOT NULL is rejected by default per alter-column-null-to-not-null.disabled. apply_changes also re-runs the create-time final-schema validations (BLOB fields and partial-update options) before persisting.
6973290 to
12d63cf
Compare
Purpose
Linked issue: close #368
Implement column-level
alter tableon bothFileSystemCatalogandRESTCatalog, and align theSchemaChangeJSON wire format with Java Paimon.Brief change log
TableSchema::apply_changes: implement add / rename / drop column, update column type / nullability / comment / position, and update table comment, mirroring JavaSchemaManager.generateTableSchema(field-id allocation, FIRST/AFTER/BEFORE/LAST moves, primary/partition-key guards). Operates on top-level columns; reusesColumnAlreadyExist/ColumnNotExist. The method keeps its single-argument signature — the catalog fills in the table name on column errors.SchemaChangeJSON with Java Paimon: internally tagged byaction, withfieldNamesarrays,comment/newDataType/keepNullability/newNullability/newCommentfields,referenceFieldNamemove anchors, and FIRST/AFTER/BEFORE/LAST move types.AlterTableRequest+RESTApi::alter_table; implementRESTCatalog::alter_table.Tests
spec::schema_change(Java-format (de)serialization),spec::schema, andcatalog::filesystem(add+move, rename syncing PK refs, drop rejecting PK columns, type/nullability/comment updates, reposition, and theColumnAlreadyExist/ColumnNotExist/TableNotExisterror paths).paimon-datafusionalter-table tests pass.API and Format
Changes the
SchemaChangeJSON wire format. This is effectively a fix: the previous format was incompatible with Java Paimon, and RESTalter_tablewas never implemented, so no working interaction is broken. No public Rust API signature change (apply_changeskeeps its arity).Documentation
None required.
Out of scope (follow-ups)
Nested struct field paths;
UpdateColumnTypecast-compatibility validation; Java'sdropPrimaryKey/updateColumnDefaultValue.