Skip to content

fix(types): assign omitted field IDs in type JSON - #380

Merged
lxy-9602 merged 1 commit into
apache:mainfrom
SteNicholas:PAIMON-347
Sep 22, 2026
Merged

lxy-9602 merged 1 commit into
apache:mainfrom
SteNicholas:PAIMON-347

Conversation

@SteNicholas

Copy link
Copy Markdown
Member

Purpose

Linked issue: close #347

Java's DataTypeJsonParser numbers the ROW fields of a parsed type when none of them carries an id, so a configured variant.shreddingSchema whose fields all omit their ids is accepted by Java Paimon but was rejected here while deserializing the first DataField (key 'id' must exist). An embedding engine therefore had to route an otherwise supported Variant write back to the Java SDK only because the configured schema omitted optional field ids.

This threads a field id assigner through the data type JSON parsing, mirroring Java's all-or-none rule:

  • ids are generated in traversal order starting at 0 when no ROW field carries one;
  • explicit ids are preserved at every level;
  • a type that mixes both forms is rejected with Partial field id is not allowed.

One deliberate deviation from Java: Java rejects the mix only when a generated id comes first, so an explicit id followed by an omitted one silently produces duplicate ids there, while both orders are rejected here. Deserializing a stored table schema still requires every field to carry its own id, as before.

Tests

  • DataTypeJsonParserTest.ParseTypeRowTypeGeneratesMissingFieldIds: ids generated in traversal order across nested ROW, ARRAY and MAP descendants.
  • DataTypeJsonParserTest.ParseTypeRowTypeSuccess: non-sequential explicit ids preserved at every level.
  • DataTypeJsonParserTest.ParseTypeComplexTypeFailure: partial ids rejected in either order, alongside the malformed complex type cases.
  • DataFieldTest.FromJson and DataFieldTest.FromJsonFailed: a stored schema still requires an id on every field, names and descriptions keep embedded NULs, and each malformed field key reports its own diagnostic.
  • VariantShreddingWritePlanFactoryTest.ConfiguredSchema: variant.shreddingSchema and its parquet.variant.shreddingSchema fallback plan the same physical schema, field ids included, whether the configured schema carries ids or omits them.
  • VariantShreddingWritePlanFactoryTest.ConfiguredSchemaRejectsPartialFieldIds.
  • VariantParquetTest.ShreddedWriteAndReadRoundTrip: the new configured-without-ids mode asserts the generated ids reach the Parquet physical schema and that the shredded values round trip.

API and Format

include/paimon/defs.h only gains documentation for variant.shreddingSchema; there is no public symbol, storage format or protocol change. A configured schema that already carries field ids produces exactly the same physical schema as before.

Documentation

docs/source/user_guide/data_types.rst documents that the configured shredding schema's fields either all carry an id or all omit one, in which case the ids are assigned in traversal order starting at 0.

Generative AI tooling

Generated-by: Claude Opus 5

🤖 Generated with Claude Code

Accept configured Variant shredding schemas whose ROW fields all omit
IDs, matching Java Paimon's preorder numbering from 0. Preserve explicit
IDs and require them when deserializing stored table schemas.

Reject partially specified IDs in either order. Java's current parser
accepts an explicit ID followed by an omitted one, which can produce
duplicate IDs; reject that case as required by apache#347.

Share the assigner across nested ROW, ARRAY and MAP types, preserve
field names and descriptions without truncation, and cover both
configuration keys and Parquet round trips with physical field IDs.

@lxy-9602 lxy-9602 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@lxy-9602

Copy link
Copy Markdown
Member

Thanks to @SteNicholas for the fix. @suxiaogang223 , could you please check again whether the issue #347 is resolved after this PR is merged? Thanks!

@lxy-9602
lxy-9602 merged commit 53800ab into apache:main Sep 22, 2026
21 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Configured Variant shredding schema without field IDs is rejected unlike Java Paimon

2 participants