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

   ### What changes were proposed in this pull request?
   
   Support CTAS (CREATE TABLE AS SELECT) in the Gravitino Trino connector by
   implementing `beginCreateTable()`, `finishCreateTable()`, and the associated
   page sink provider and handle wrapper.
   
   The key design choice is that `beginCreateTable()` first creates the table in
   the Gravitino catalog, then delegates data writing to the internal 
connector's
   `beginInsert()` path. This avoids double table creation in the original
   connector.
   
   **Files changed:**
   - `GravitinoMetadata.java` — `beginCreateTable()` creates table via 
Gravitino, then calls `internalMetadata.beginInsert()`; `getNewTableLayout()` 
delegates to internal
   - `GravitinoOutputTableHandle.java` — **new** handle wrapper that wraps 
`ConnectorInsertTableHandle` (implements `ConnectorOutputTableHandle`)
   - `GravitinoMetadata{435,440,446,452,469,478}.java` — version-specific 
`finishCreateTable()` delegating to `finishInsert()`
   - `GravitinoPageSinkProvider.java` — `createPageSink(OutputTableHandle)` 
unwraps to insert handle and uses insert-path sink
   - `JsonCodec.java` — registered `ConnectorOutputTableHandle` in 
`AbstractTypedJacksonModule` for polymorphic serialization
   
   ### Why are the changes needed?
   
   CTAS is a standard SQL pattern commonly used during lakehouse migrations, ETL
   development, and exploratory data work. Without it, users must use a two-step
   `CREATE TABLE` + `INSERT INTO` pattern, which introduces a failure mode where
   partial table registrations can be left behind if the insert fails.
   
   Fix: #10750
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. Users can now execute `CREATE TABLE ... AS SELECT` queries through the
   Gravitino Trino connector. Previously this returned:
   `This connector does not support creating tables with data.`
   
   ### How was this patch tested?
   
   - Added `testCreateTableAsSelect` test in `TestGravitinoConnector`
   - All existing tests pass across all 6 Trino SPI version modules (435–478)
   - Ran `./gradlew spotlessApply` for formatting compliance


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