jerryshao commented on code in PR #9127:
URL: https://github.com/apache/gravitino/pull/9127#discussion_r2709663546
##########
lance/lance-common/src/main/java/org/apache/gravitino/lance/common/ops/gravitino/GravitinoLanceTableOperations.java:
##########
@@ -284,6 +297,63 @@ public DropTableResponse dropTable(String tableId, String
delimiter) {
return response;
}
+ @Override
+ public AlterTableDropColumnsResponse alterTableDropColumns(
+ String tableId, String delimiter, AlterTableDropColumnsRequest request) {
+ ObjectIdentifier nsId = ObjectIdentifier.of(tableId,
Pattern.quote(delimiter));
+ Preconditions.checkArgument(
+ nsId.levels() == 3, "Expected at 3-level namespace but got: %s",
nsId.levels());
+
+ String catalogName = nsId.levelAtListPos(0);
+ Catalog catalog =
namespaceWrapper.loadAndValidateLakehouseCatalog(catalogName);
+
+ NameIdentifier tableIdentifier =
+ NameIdentifier.of(nsId.levelAtListPos(1), nsId.levelAtListPos(2));
+
+ TableChange[] changes =
+ request.getColumns().stream()
+ .map(colName -> TableChange.deleteColumn(new String[] {colName},
false))
+ .toArray(TableChange[]::new);
+
+ catalog.asTableCatalog().alterTable(tableIdentifier, changes);
+
+ return new AlterTableDropColumnsResponse();
+ }
+
+ @Override
+ public AlterTableAlterColumnsResponse alterTableAlterColumns(
+ String tableId, String delimiter, AlterTableAlterColumnsRequest request)
{
+ ObjectIdentifier nsId = ObjectIdentifier.of(tableId,
Pattern.quote(delimiter));
+ Preconditions.checkArgument(
+ nsId.levels() == 3, "Expected at 3-level namespace but got: %s",
nsId.levels());
+
+ String catalogName = nsId.levelAtListPos(0);
+ Catalog catalog =
namespaceWrapper.loadAndValidateLakehouseCatalog(catalogName);
+
+ NameIdentifier tableIdentifier =
+ NameIdentifier.of(nsId.levelAtListPos(1), nsId.levelAtListPos(2));
+
+ List<TableChange> changes = buildAlterColumnChanges(request);
+ if (changes.isEmpty()) {
+ LOGGER.warn("No valid alterations found in the request for table: {}",
tableId);
+ throw new IllegalArgumentException("No valid alterations found in the
request.");
+ }
+ catalog.asTableCatalog().alterTable(tableIdentifier, changes.toArray(new
TableChange[0]));
+
+ AlterTableAlterColumnsResponse response = new
AlterTableAlterColumnsResponse();
+ response.setVersion(0L);
Review Comment:
What's the meaning here?
--
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]