bbiiaaoo commented on code in PR #12383:
URL: https://github.com/apache/gravitino/pull/12383#discussion_r3763309747
##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/lance/LanceTableOperations.java:
##########
@@ -811,6 +837,78 @@ Dataset openDataset(String location, Map<String, String>
storageOptions) {
.build();
}
+ private List<Field> prepareFieldsToAdd(TableChange[] changes) {
+ Preconditions.checkArgument(changes != null && changes.length > 0,
"Changes cannot be empty");
+
+ int addColumnCount = 0;
+ for (TableChange change : changes) {
+ Preconditions.checkArgument(change != null, "Table change cannot be
null");
+ if (change instanceof TableChange.AddColumn) {
+ addColumnCount++;
+ } else if (!(change instanceof TableChange.DeleteColumn)
+ && !(change instanceof TableChange.AddIndex)
+ && !(change instanceof TableChange.RenameColumn)) {
+ throw new UnsupportedOperationException(
+ "Unsupported changes to lance table: " +
change.getClass().getSimpleName());
+ }
+ }
+
+ if (addColumnCount == 0) {
+ return List.of();
+ }
+
+ Preconditions.checkArgument(
+ addColumnCount == changes.length,
+ "Lance AddColumn cannot be combined with other table changes");
+
+ Set<String> columnNames = new HashSet<>();
+ List<Field> fieldsToAdd = new ArrayList<>(changes.length);
+ for (TableChange change : changes) {
Review Comment:
Thanks for the suggestion. I merged AddColumn detection, validation, and
Arrow field construction into a single loop.
--
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]