FANNG1 commented on PR #12383: URL: https://github.com/apache/gravitino/pull/12383#issuecomment-5216167112
### Code review Found 1 issue: 1. `AddColumn` deterministically fails on declared-only or empty-stored-columns tables. `alterTable` loads the entity via `loadTableEntity(ident)`, a raw `store.get()` that bypasses the repair-on-load logic in `loadTable`, and `TableOperationDispatcher.alterTable` does not call `loadTable` beforehand. The new `addColumns` then builds `expectedCurrentFields` from `table.columns()` and hard-checks it against the real dataset schema, so for a declared table (`lance.declared=true`, created with `new Column[0]`) or a table whose stored columns are still empty — both normal states under the default `DECLARED_AND_EMPTY` refresh mode, per the class Javadoc — the pre-check throws a misleading `OptimisticLockException` about schema inconsistency. The pre-existing DeleteColumn/RenameColumn/AddIndex paths are unaffected because they never consult `table.columns()`. No test covers add-column against a declared or empty-stored-columns table. https://github.com/apache/gravitino/blob/dccd7db3387b233f62a6b41370445e5adad502e5/catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/lance/LanceTableOperations.java#L309-L313 https://github.com/apache/gravitino/blob/dccd7db3387b233f62a6b41370445e5adad502e5/catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/lance/LanceTableOperations.java#L831-L839 🤖 Generated with [Claude Code](https://claude.ai/code) <sub>- If this code review was useful, please react with 👍. Otherwise, react with 👎.</sub> -- 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]
