bbiiaaoo commented on code in PR #12383:
URL: https://github.com/apache/gravitino/pull/12383#discussion_r3763315718
##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/lance/LanceTableOperations.java:
##########
@@ -754,10 +766,24 @@ private GenericColumn toGenericColumn(ColumnEntity
columnEntity) {
* @return the new version id of the Lance dataset after applying the changes
*/
long handleLanceTableChange(Table table, TableChange[] changes) {
+ List<Field> fieldsToAdd = prepareFieldsToAdd(changes);
+ validateFieldsToAdd(table, fieldsToAdd);
+ return handleLanceTableChange(table, changes, fieldsToAdd);
+ }
+
+ private long handleLanceTableChange(Table table, TableChange[] changes,
List<Field> fieldsToAdd) {
String location = table.properties().get(Table.PROPERTY_LOCATION);
Map<String, String> storageOptions =
LancePropertiesUtils.resolveLanceStorageOptions(catalogProperties,
table.properties());
try (Dataset dataset = openDataset(location, storageOptions)) {
+ if (!fieldsToAdd.isEmpty()) {
+ // Adding all fields in one call creates one Lance schema version and
backfills existing
+ // rows with null for the new nullable columns.
+ dataset.addColumns(fieldsToAdd);
+ dataset.checkoutLatest();
Review Comment:
Mixed AddColumn and other table changes are rejected because the Lance
physical schema update must be completed separately from the existing
alter-table operations.
I added explicit tests for AddColumn combined with DeleteColumn in both
orders, as well as AddColumn combined with AddIndex.
--
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]