Added support for add column and drop column#41
Conversation
| Types.NestedField field; | ||
|
|
||
| switch (type.toLowerCase()) { | ||
| case "string": |
There was a problem hiding this comment.
couldn't find any mapper from string to iceberg Types
| return new ColumnSpec(columnName, field.type(), comment); | ||
| } | ||
|
|
||
| private static Types.NestedField parseColumnType(String name, String type, String comment) { |
There was a problem hiding this comment.
maybe this needs to be moved to a common class for field mapping.
There was a problem hiding this comment.
I think we should go with @aadant's proposal #39 (comment). Separate add-column/delete-column commands instead of single alter-table means you can't combine multiple changes in a single transaction.
Invalid operation |
| names = {"--operations"}, | ||
| required = true, | ||
| description = | ||
| "JSON array of operations: [{'add': 'age:int:User age'}, {'drop': 'col_name'}]") |
There was a problem hiding this comment.
It would be best to stick to yaml/json for this as column names may contain colons, future operations may not be so easy to express in colon-separated values, etc.
It would also be nice if operation/files names would follow https://iceberg.apache.org/docs/latest/spark-ddl/#alter-table-rename-column naming.
There was a problem hiding this comment.
alter-table flowers.iris --operations '[{"operation": "add column", "column_name": "age", "type": "int", "comment": "user age"}]'
2025-07-16 16:12:24 [main] INFO c.a.i.c.i.cmd.AlterTable > Adding column 'age' to table: flowers.iris
2025-07-16 16:12:24 [main] INFO c.a.i.c.i.cmd.AlterTable > Successfully applied 1 operations to table: flowers.iris
ice alter-table flowers.iris --operations '[{"operation": "drop column", "column_name": "age"}]'
2025-07-16 16:12:48 [main] INFO c.a.i.c.i.cmd.AlterTable > Dropping column 'age' from table: flowers.iris
2025-07-16 16:12:49 [main] INFO c.a.i.c.i.cmd.AlterTable > Successfully applied 1 operations to table: flowers.iris
alter-table flowers.iris --operations '[{"operation": "drop column", "column_name": "age"}, {"operation": "add column", "column_name": "marital_status", "type": "string", "comment": "Marital Status"}]'
2025-07-16 16:35:47 [main] INFO c.a.i.c.i.cmd.AlterTable > Dropping column 'age' from table: flowers.iris
2025-07-16 16:35:47 [main] INFO c.a.i.c.i.cmd.AlterTable > Adding column 'marital_status' to table: flowers.iris
2025-07-16 16:35:47 [main] INFO c.a.i.c.i.cmd.AlterTable > Successfully applied 2 operations to table: flowers.iris
|
Can you please confirm that this scenario works:
|
…-to-an-existing-table
|
|
Included in 0.9.0. |
closes: #39