Repository navigation
[datafusion] Support persistent CREATE TABLE AS SELECT - #1448
SteNicholas wants to merge 1 commit into
Conversation
5224a29 to
750c4d4
Compare
JingsongLi
left a comment
There was a problem hiding this comment.
Persistent CTAS has end-to-end value. All 19 CTAS cases and 103 related DataFusion cases passed locally. The filesystem catalog change below blocks ordinary table creation on existing backends.
750c4d4 to
178d008
Compare
|
@JingsongLi, thanks for running the CTAS and DataFusion suites. I fixed the ordinary All 19 CTAS tests passed on this revision. The catalog regression test disables conditional write and rename on a local filesystem operator, registers an existing Parquet file as a Format Table, and reads its rows back. Regression test Rebased |
JingsongLi
left a comment
There was a problem hiding this comment.
Persistent CTAS has end-to-end value. I reran the ordinary CREATE regression with conditional writes and renames disabled, along with the strict creation race and conditional rename error tests. All 48 filesystem catalog tests, the REST create case, 19 existing CTAS tests and 92 related DataFusion tests passed. The additional existing-target probe found the no-op issue below.
e487175 to
f78635d
Compare
JingsongLi
left a comment
There was a problem hiding this comment.
Reviewed f78635d4 for CTAS correctness and SQL compatibility.
f78635d to
da3a947
Compare
da3a947 to
690b10e
Compare
|
Thanks for the review, @JingsongLi. All four fixes are in
|
JingsongLi
left a comment
There was a problem hiding this comment.
Persistent CTAS addresses the materialization workflow in #1425. On 8aa3030c, 123 DataFusion tests, 172 REST catalog tests, and targeted conditional-publication tests passed, including lost S3 responses. One ordinary CREATE compatibility issue remains.
690b10e to
d1314eb
Compare
|
Thanks for reviewing and running the tests, @JingsongLi. The ordinary On the updated head, 1,095 focused tests passed on Rust 1.98.0 (594 DataFusion, 328 core with S3 enabled, and 173 REST catalog), including the lost S3 response and mount fallback regressions. Formatting and |
JingsongLi
left a comment
There was a problem hiding this comment.
Persistent CTAS covers the durable materialization workflow in #1425. On d1314eb3, I reran 41 existing CTAS, time-travel, and read_files tests, 26 matching core publication tests, and 25 existing S3 tests. The native mount fallback and S3 lost-response cases pass locally. I reproduced a wrong result in an existing snapshot join and a compatibility failure in ordinary filesystem CREATE TABLE against an S3 mock. The Windows unit job also fails both new native publication tests. Windows CI
0f32e5a to
c0e1c68
Compare
|
Thanks for reproducing these issues, @JingsongLi. The three fixes are on the updated PR head. Review · Commit
Before the CI dependency fixes, 400 focused tests passed on macOS with Rust 1.98.0 (41 DataFusion, 185 core with S3 enabled, and 174 REST catalog). The standalone GCS compilation check, formatting and The amended commit also adds the missing |
c0e1c68 to
b5efd68
Compare
JingsongLi
left a comment
There was a problem hiding this comment.
Persistent CTAS has clear end-to-end value. GitHub CI is green on this head. I reran the filesystem publication, S3 and REST suites locally, including the earlier fallback cases. A separate filesystem CTAS and read-back comparison reproduced the wrong-result case below.
|
Thanks for rerunning the publication suites and reproducing the CTAS read-back issue, @JingsongLi. Unaliased snapshot scans now use distinct statement-local qualifiers. The planner rewrites exact visible snapshot references, so The regression reads both CTAS destinations back through a fresh SQL context. Both |
JingsongLi
left a comment
There was a problem hiding this comment.
Persistent CTAS addresses a real materialization workflow. The 42 local DataFusion CTAS, snapshot-schema, and read_files integration tests passed on 39e4a496.
Integration is currently blocked. Merging this head with main at d557fb13 conflicts in crates/paimon/src/catalog/filesystem.rs and crates/paimon/src/catalog/rest/rest_catalog.rs. Please rebase and rerun the filesystem and REST publication tests on the resolved result.
39e4a49 to
1b0f369
Compare
|
Thanks for checking this against Both ordinary and exclusive table creation now apply upstream’s reserved-name checks. REST creation still maps missing databases to On the rebased head, all 90 catalog unit tests, 174 REST catalog integration tests, and 103 DataFusion integration tests passed. That includes the filesystem create race, the fallback for ordinary creation, and REST exclusive creation. |
1b0f369 to
851fb39
Compare
JingsongLi
left a comment
There was a problem hiding this comment.
Persistent CTAS has end-to-end value. On 851fb39a, I ran 197 DataFusion integration tests, 174 REST catalog integration tests, and 26 S3 unit tests. A deterministic filesystem-catalog test reproduced the destination identity race below.
Materializing a DataFusion query in Paimon required separate CREATE and INSERT statements. Issue apache#1425 calls for a single statement that infers the destination schema and populates the table. - Infer column names, types and nullability from a bounded query and reuse the analyzed plan. Apply table options, keys and partitioning. - Resolve sources and SQL functions in the session namespace. Preserve quoted names, snapshot bindings and nested field access. - Check target metadata before planning. Skip existing targets and definite create conflicts with IF NOT EXISTS. - Require atomic creation for CTAS. Preserve ordinary CREATE on storage without conditional publication. - Bind writes to the created table and share lifecycle locks across warehouse aliases. Use a dedicated REST create endpoint and validate the table identity and base snapshot before publication. - Discard owned uncommitted files on failure or cancellation. Retain files when publication is uncertain. - Cover persisted results, competing creates, table replacement and stale REST commits. Document CTAS syntax and recovery behavior.
851fb39 to
f50867c
Compare
|
Thanks for running those suites and for the deterministic reproducer, @JingsongLi. Both findings from your review are addressed in
On macOS with Rust 1.98.0, 231 integration tests, 437 DataFusion unit tests, and 5,204 core unit tests with |
Purpose
Closes #1425.
Materialize a bounded, read-only DataFusion query as a persistent native Paimon table in one statement. The query supplies the destination schema even when it returns no rows.
scoresresolves in the session's current catalog and database, independently of the destination.Brief change log
IF NOT EXISTSskips existing targets and definite create conflicts. An uncertain create outcome returns an error.Tests
Verified on macOS with Rust 1.98.0. Tested commit
read_files, the REST catalog and the bundled REST server. Regression cases cover destination replacement before and during population, competing REST creates, stale snapshot commits, and writes after schema evolution.storage-s3enabled, with 8 ignored. Coverage includes ordinary CREATE fallback, conditional publication and lost S3 responses.cargo fmt --all -- --checkandgit diff --checkpassed.API and Format
Catalog::check_table_existsdefaults to a table load. Filesystem and REST catalogs use metadata-only lookups.Catalog::create_table_exclusivereturns the created table handle or an unsupported-operation error. Filesystem CTAS requires atomic, no-overwrite publication of the initial schema. Ordinary CREATE retains its plain-write fallback on storage where conditional publication is definitively unavailable.POST /v1/databases/{db}/exclusive-tablesunder the configured catalog prefix. The endpoint must enforce exclusive creation and return the initial metadata and identity of the managed native Paimon table. A server without the endpoint can still serve ordinary CREATE.creationUuidin the initial schema metadata. CTAS uses the existing Paimon snapshot and data-file formats.Documentation
The SQL reference covers supported syntax and types, storage requirements, and recovery after an uncertain create or commit. The DataFusion README includes a session-namespace example. SQL reference · DataFusion README
🤖 Assisted with Codex.