feat(c): build a catalog-free Table from a resolved schema JSON - #595
Open
JunRuiLee wants to merge 1 commit into
Open
feat(c): build a catalog-free Table from a resolved schema JSON#595JunRuiLee wants to merge 1 commit into
JunRuiLee wants to merge 1 commit into
Conversation
JunRuiLee
force-pushed
the
feat/table-descriptor
branch
2 times, most recently
from
July 28, 2026 08:31
83f2db7 to
7636fda
Compare
JunRuiLee
marked this pull request as ready for review
July 28, 2026 08:33
JunRuiLee
marked this pull request as draft
July 28, 2026 08:40
JunRuiLee
force-pushed
the
feat/table-descriptor
branch
from
July 28, 2026 12:17
7636fda to
ed3e54c
Compare
Add a catalog-free way to build a Table from an already-resolved Paimon TableSchema, so a non-Java engine (e.g. Doris via the C FFI) can rebuild a table for scan/read without a catalog lookup. Today the only way to obtain a Table is Catalog::get_table, which re-resolves the table (risking schema/ snapshot drift versus what the planner already resolved) and ties the reader to a filesystem-catalog layout. The caller passes everything a reader needs directly: table path, the full TableSchema JSON (preserved as-is, not re-loaded or normalized), database/ table name, branch, and filesystem options. The Rust side constructs the Table with a plain FileIO and rest_env = None; branch only selects the branch-scoped schema/snapshot/tag managers. Reads can still use FE-generated splits via paimon_plan_from_split_bytes. Mirroring Java FileStoreTableFactory.create(fileIO, path, schema), the table stays a normal (writable) table; existing non-main-branch / time-travel write guards apply. Validate the externally supplied schema's structural invariants without normalizing it (TableSchema::validate_resolved_structure): reject duplicate field names, duplicate field ids (including nested), primary-key/partition columns that do not exist, primary keys that are exactly the partition columns (the read path would panic on a zero-column key), and reserved system field names/ids (e.g. a user _ROW_ID column would be silently replaced by the system row number on read). Create-time policy checks (merge-engine/changelog/ aggregation/rowkind/blob strategy, bucket-key existence) are intentionally not run, since they normalize the schema or reject shapes that are valid to read. - crates/paimon/src/table/mod.rs: Table::from_resolved_schema. - crates/paimon/src/spec/schema.rs: TableSchema::validate_resolved_structure. - bindings/c/src/table.rs: paimon_table_from_schema_json (nullable branch defaults to main), mirroring the paimon_catalog_get_table handle/free contract with an ABI signature guard; freed via paimon_table_free. Known pre-existing limitations, unreachable via the split-bytes read path Doris uses, are left for follow-ups: incremental scan uses a root SnapshotManager for non-main branches; time-travel selectors embedded in schema JSON options are not honored by the plain read builder; a stale path option is preferred by FormatTableScan over the table location; a non-existent bucket-key is silently dropped on write (write path only); full Java-parity SchemaValidation is not mirrored.
JunRuiLee
force-pushed
the
feat/table-descriptor
branch
from
July 28, 2026 13:08
ed3e54c to
c387895
Compare
JunRuiLee
marked this pull request as ready for review
July 28, 2026 13:19
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.
Purpose
Add a catalog-free way to build a read-only-oriented
Tablefrom an already-resolved PaimonTableSchema, so a non-Java engine (e.g. Doris FE/BE via the C FFI) can rebuild a table for scan/read without a catalog lookup.Today the only way to obtain a
TableisCatalog::get_table, which re-resolves the table — risking schema/snapshot drift versus what the planner (the FE) already resolved — and ties the reader to a filesystem-catalog layout.An earlier iteration proposed a dedicated
TableDescriptorabstraction on the Java side to bundle path/schema/branch. The community felt it lacked sufficient motivation: it would re-define Paimon table metadata on the Java side and couple the paimon-rust interface to Doris integration details. That approach is dropped in favor of this generic, catalog-free entry point.Design
The caller (Doris FE) passes everything a reader needs directly:
table_path— the table locationtable_schema_json— the fullTableSchemaJSON, already resolved by the FE (parsed with the existing serdeTableSchemashape; preserved as-is, not re-loaded, normalized, or overridden)database/table_name— used to synthesize the tableIdentifierbranch— selects the branch-scoped managers (schema/snapshot/tag read paths); nullable, defaults tomainstorage_options— used only to buildFileIO; they are not merged into the supplied schemaThe Rust side constructs the
Tabledirectly: noCatalog, no warehouse derivation, and no re-resolution of the FE-provided schema.branchonly decides which branch's schema/snapshot/tag paths reads follow; reads can still use FE-generated splits (paimon_plan_from_split_bytes), and Rust-side time travel remains available through the existing read-builder options.Aligning with Java
FileStoreTableFactory.create(fileIO, path, schema)(which usesCatalogEnvironment.empty()), the constructed table is a normal table — not made artificially read-only — and the existing non-main-branch / time-travel write guards still apply.Brief change log
crates/paimon/src/table/mod.rs:Table::from_resolved_schema(file_io, identifier, location, schema, branch)— preserves the supplied schema as-is, validates the identifier and branch name, validates the schema's structural invariants, wires a branch-scopedSchemaManager, setsrest_env = Noneand no time travel.crates/paimon/src/spec/schema.rs:TableSchema::validate_resolved_structure()— a non-mutating structural check for externally supplied schema JSON: duplicate field names, duplicate field ids (incl. nested), primary-key/partition column existence, primary keys not being exactly the partition columns (which would panic the read path on a zero-column key), and reserved system field names/ids (e.g. a user_ROW_IDcolumn would otherwise be silently replaced by the system row number). It intentionally does not run create-time policy checks (merge-engine/changelog/aggregation/rowkind/blob strategy), which normalize the schema or reject shapes that are valid to read.bindings/c/src/table.rs: C FFIpaimon_table_from_schema_json(table_path, table_schema_json, database, table_name, branch, storage_options, storage_options_len), mirroring the existingpaimon_catalog_get_tablehandle/free contract, with an ABI signature guard.branchmay be null (defaults tomain); a non-null pointer is still fully UTF-8 and branch-name validated. Freed viapaimon_table_free.paimon_table_from_schema_jsonis also a valid source.schema/schema-NbySchemaManager; the resolved schema pins the planned/current schema only.Tests
paimon-cFFI tests: build a table from a resolved schema; null-branch defaults tomain; invalid branch name (../dev) rejected; malformed JSON rejected; null-pointer / nullstorage_optionswith non-zero length rejected; invalid identifier rejected; missing primary-key column rejected.paimonunit tests forvalidate_resolved_structure: accepts a valid schema; rejects missing primary-key column, missing partition column, duplicate field names, and duplicate field ids.Not in this PR (known, pre-existing scan-planning limitations, independent of this entry point)
These are not introduced by this change and are unreachable through the read path Doris uses (
paimon_plan_from_split_bytesreading FE-generated splits):IncrementalScanbuilds a root (main-branch)SnapshotManager, so incremental scans of a non-main branch would read the main branch's snapshots (Rust-side scan planning only).pathoption embedded in the schema JSON is preferred byFormatTableScanover the table location (Rust-side format scan planning only; normal-table reads use the table location and are unaffected).bucket-keyis silently dropped and all data is written to bucket 0 — a write-path concern only; this entry point is for reading.SchemaValidation(option-combination policy checks) is not mirrored; only the structural invariants above are enforced.API and Format
paimon::table::Table::from_resolved_schema, and C FFIpaimon_table_from_schema_json(additive; existing symbols unchanged).TableSchemaJSON.Documentation
None yet (new, evolving C FFI surface for the Doris integration); docs can follow once the integration stabilizes.