[#10750] feat(trino-connector): Support CTAS (CREATE TABLE AS SELECT)#10757
Open
laserninja wants to merge 1 commit intoapache:mainfrom
Open
[#10750] feat(trino-connector): Support CTAS (CREATE TABLE AS SELECT)#10757laserninja wants to merge 1 commit intoapache:mainfrom
laserninja wants to merge 1 commit intoapache:mainfrom
Conversation
Code Coverage Report
Files
|
…ELECT) Implement beginCreateTable/finishCreateTable in the Gravitino Trino connector to support CREATE TABLE AS SELECT queries. The approach creates the table in Gravitino catalog first, then delegates data writing to the internal connector's insert path, avoiding double table creation in the original connector. Changes: - GravitinoMetadata: beginCreateTable delegates to beginInsert - GravitinoOutputTableHandle: wraps ConnectorInsertTableHandle - GravitinoPageSinkProvider: routes output handle to insert sink - JsonCodec: register ConnectorOutputTableHandle for Jackson - Version-specific finishCreateTable in all 6 SPI subclasses - TestGravitinoConnector: add testCreateTableAsSelect test Closes apache#10750
61dab9d to
1d6aa6f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 associatedpage sink provider and handle wrapper.
The key design choice is that
beginCreateTable()first creates the table inthe Gravitino catalog, then delegates data writing to the internal connector's
beginInsert()path. This avoids double table creation in the originalconnector.
Files changed:
GravitinoMetadata.java—beginCreateTable()creates table via Gravitino, then callsinternalMetadata.beginInsert();getNewTableLayout()delegates to internalGravitinoOutputTableHandle.java— new handle wrapper that wrapsConnectorInsertTableHandle(implementsConnectorOutputTableHandle)GravitinoMetadata{435,440,446,452,469,478}.java— version-specificfinishCreateTable()delegating tofinishInsert()GravitinoPageSinkProvider.java—createPageSink(OutputTableHandle)unwraps to insert handle and uses insert-path sinkJsonCodec.java— registeredConnectorOutputTableHandleinAbstractTypedJacksonModulefor polymorphic serializationWhy 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 INTOpattern, which introduces a failure mode wherepartial 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 SELECTqueries through theGravitino Trino connector. Previously this returned:
This connector does not support creating tables with data.How was this patch tested?
testCreateTableAsSelecttest inTestGravitinoConnector./gradlew spotlessApplyfor formatting compliance