[lake/paimon] Support clean and legacy Paimon lake table schemas - #3982
Open
fhan688 wants to merge 1 commit into
Open
[lake/paimon] Support clean and legacy Paimon lake table schemas#3982fhan688 wants to merge 1 commit into
fhan688 wants to merge 1 commit into
Conversation
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
Linked issue: close #3902
Sub-task of the FIP-27 umbrella (#2411): Remove Mandatory System Columns From Fluss Lake Tables.
Today every Paimon lake table Fluss creates is forced to carry three mandatory system columns (
__bucket,__offset,__timestamp) as its last physical columns. They pollute the schema users see from Paimon and other engines, and impose a system-metadata-based physical layout.This PR implements the Paimon part of FIP-27: newly created Paimon lake tables use a clean physical schema containing only user-defined columns, while existing legacy tables that still carry the three system columns remain fully readable and writable without any schema migration. Both layouts are supported across create, tiering writers, readers, projections, schema evolution, and re-enabling tiering.
Brief change log
PaimonSystemColumnswith aLakeLayoutenum anddetectLayout(RowType). Detection is purely schema-based — no new table property or metadata, so existing tables are never migrated:CLEAN;LEGACY;InvalidTableException.PaimonConversions.toPaimonSchemano longer appends the system columns; new tables are clean. The user-column name-conflict check against system names is kept.toPaimonSchemaChangesnow takes the target layout — for a legacy table a new business column is still inserted before the first system column; for a clean table it is appended normally.PaimonTableValidation.isPaimonSchemaCompatibledetects the existing layout and, for a legacy table, enriches the freshly generated clean schema with the trailing system columns before comparison, so disabling and re-enabling tiering preserves the existing physical layout. The__timestampprecision-6→3 relaxation is guarded so it only applies to legacy tables (a clean table has no__timestamp).FlussRecordAsPaimonRowemits the three system values only for legacy tables; for clean tables the business-field count equals the full row and no system fields are written. Layout is threaded throughPaimonLakeWriter→RecordWriter→AppendOnlyWriter/MergeTreeWriter.AppendOnlyArrowBatchHelperwrites the originalVectorSchemaRootdirectly; for legacy tables it keeps enriching the batch with the__bucket/__offset/__timestampvectors.PaimonRecordReaderprojects and reads__offset/__timestamponly for legacy tables. For clean tables it emits a sentinel-1log offset / timestamp, consistent with the existingLakeRecordRecordEmittercontract (logOffset() >= 0marks the incremental phase) and the existingUNKNOWN_OFFSET = -1convention.PaimonRowAsFlussRowno longer assumes a fixed number of trailing system columns globally; the trailing-system-column count is explicit, which also fixes latent miscounts for nested/projected rows (e.g. the lookup path, where Paimon already projects system columns away).Tests
FlussRecordAsPaimonRowTestto the layout-aware writer (existing cases are legacy-layout).FULLstartup; disable+re-enable preserves layout; row and Arrow-batch writer paths; reader projections; schema evolution; and rejection of a partial/type-incompatible legacy layout. Cases should span log and primary-key tables, and partitioned and non-partitioned tables.mvn clean verifyhas not been run locally (JDK 11 build environment not available on my machine; only JDK 8). Verified signature consistency, imports, and static review; full compile + IT run is pending on a JDK 11 environment.API and Format
No public API change. This changes the physical schema of newly created Paimon lake tables (clean layout by default). Existing tables are not migrated and keep their current physical format. Compatibility / rolling-upgrade requirements are covered by the umbrella #2411 and documented in #3905:
FULLstartup mode must not read newly created clean tables.Fluss cluster.
Documentation
Feature behavior (clean vs. legacy layouts, detection, and the rolling-upgrade/compatibility matrix) is documented separately under #3905. No standalone doc change in this PR.