FANNG1 commented on code in PR #12383:
URL: https://github.com/apache/gravitino/pull/12383#discussion_r4056588347
##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/lance/LanceTableOperations.java:
##########
@@ -812,10 +826,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();
+ return dataset.getVersion().getId();
+ }
+
for (TableChange change : changes) {
if (change instanceof TableChange.DeleteColumn deleteColumn) {
Review Comment:
could you add `add column` here? move all add column related logic in one
place
--
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]