jerryshao opened a new pull request, #9279:
URL: https://github.com/apache/gravitino/pull/9279

   ### What changes were proposed in this pull request?
   
   This PR improves Lance table creation to support three creation modes 
(CREATE, EXIST_OK, OVERWRITE) by passing the mode as a property rather than 
using exception-based flow control.
   
   **Key changes:**
   - Add `LANCE_CREATION_MODE` property to support CREATE, EXIST_OK, and 
OVERWRITE modes
   - Refactor `LanceTableOperations.createTable()` to handle all three creation 
modes upfront
   - Add `CreationMode` enum (CREATE, EXIST_OK, OVERWRITE) to 
`LanceTableOperations`
   - Extract `createTableInternal()` method to handle actual table creation 
logic
   - Simplify `GravitinoLanceTableOperations` to pass mode via property instead 
of exception handling
   - Centralize Lance-related constants in `LanceConstants` class
   - Automatically mark registered tables as external to preserve physical 
datasets
   - Add comprehensive unit tests and integration tests
   
   ### Why are the changes needed?
   
   Fix: #9277
   
   The current implementation uses exception handling (catch 
TableAlreadyExistsException) to handle different creation modes, which requires 
multiple round-trip requests and complicates the code. This change:
   1. Eliminates multiple round-trip requests for EXIST_OK and OVERWRITE modes
   2. Improves performance by handling modes server-side in a single request
   3. Simplifies codebase by removing exception-based flow control
   4. Makes the API more consistent and easier to maintain
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, users can now specify the `lance.creation-mode` property when creating 
or registering Lance tables:
   - `CREATE` (default): Fails if table already exists
   - `EXIST_OK`: Returns existing table if found, creates if not
   - `OVERWRITE`: Drops/purges existing table and creates new one
   
   ### How was this patch tested?
   
   - Added unit tests in `TestLanceTableOperations` for mode validation and 
error handling
   - Added integration tests in `CatalogGenericCatalogLanceIT` for:
     - createTable with CREATE, EXIST_OK, and OVERWRITE modes
     - registerTable with CREATE, EXIST_OK, and OVERWRITE modes
   - Existing tests in `LanceRESTServiceIT` already cover end-to-end scenarios
   - All tests passing


-- 
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]

Reply via email to