Skip to content

feat: support Iceberg v3 unknown type#662

Open
manuzhang wants to merge 3 commits into
apache:mainfrom
manuzhang:codex/support-unknown-v3-type
Open

feat: support Iceberg v3 unknown type#662
manuzhang wants to merge 3 commits into
apache:mainfrom
manuzhang:codex/support-unknown-v3-type

Conversation

@manuzhang
Copy link
Copy Markdown
Member

@manuzhang manuzhang commented May 20, 2026

Closes #665


Summary

  • Add Iceberg v3 unknown primitive type and JSON serialization/deserialization support.
  • Support unknown as null-only data across Arrow, Avro, Parquet, schema projection, and nested fields.
  • Enforce required-field invariants for unknown/null-only projections and Arrow null imports.

Validation

  • ctest --test-dir build --output-on-failure

Co-authored-by: @codex

@manuzhang manuzhang marked this pull request as ready for review May 20, 2026 11:10
Comment thread src/iceberg/schema_util.cc
Comment thread src/iceberg/test/update_schema_test.cc Outdated
Comment thread src/iceberg/parquet/parquet_writer.cc Outdated
@wgtmac
Copy link
Copy Markdown
Member

wgtmac commented May 22, 2026

Please rebase on the latest main as well.

manuzhang and others added 2 commits May 22, 2026 17:06
Add an Iceberg unknown primitive type and JSON, Arrow, Avro, Parquet, projection, and data path support for null-only unknown fields. Enforce optionality invariants so required projections cannot be materialized from unknown/null-only fields.

Co-authored-by: Codex <codex@openai.com>
Enforce unknown as a v3-only optional type in schema validation and update paths, allow schema-update promotion from unknown to primitive types, reject unknown-to-nested projection, and reject unsupported Parquet writes for unknown list or map leaves.

Co-authored-by: Codex <codex@openai.com>
@manuzhang manuzhang force-pushed the codex/support-unknown-v3-type branch from 26ccf9b to 8087ed1 Compare May 22, 2026 09:19
Assert that promotion helpers reject nested type targets for unknown and regular primitive source types.

Co-authored-by: Codex <codex@openai.com>
@manuzhang manuzhang force-pushed the codex/support-unknown-v3-type branch from eb195ac to d2a34b5 Compare May 22, 2026 09:50
@wgtmac
Copy link
Copy Markdown
Member

wgtmac commented May 23, 2026

Could you please rebase to resolve conflicts? PR for v3 nano precision timestamp types has been merged.


TEST(SchemaJsonTest, NestedUnknownFieldsRoundTrip) {
constexpr std::string_view json =
R"({"fields":[{"id":1,"name":"profile","required":false,"type":{"fields":[{"id":2,"name":"mystery","required":false,"type":"unknown"}],"type":"struct"}},{"id":3,"name":"mysteries","required":false,"type":{"element":"unknown","element-id":4,"element-required":false,"type":"list"}},{"id":5,"name":"properties","required":false,"type":{"key":"string","key-id":6,"type":"map","value":"unknown","value-id":7,"value-required":false}}],"schema-id":1,"type":"struct"})";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: It would be more readable if we made this multi-line.

constexpr std::string_view json =
R"({"fields":[{"id":1,"name":"mysteries","required":false,"type":{"key":"unknown","key-id":2,"type":"map","value":"string","value-id":3,"value-required":false}}],"schema-id":1,"type":"struct"})";

auto schema_result = SchemaFromJson(nlohmann::json::parse(json));
Copy link
Copy Markdown
Collaborator

@zhjwpku zhjwpku May 24, 2026

Choose a reason for hiding this comment

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

From the spec: Map keys are required and map values can be either optional or required. So I'm wondering should we report something like Map 'key' can not be unknown type rather than the current error msg?

Comment thread src/iceberg/json_serde.cc
ICEBERG_ASSIGN_OR_RAISE(auto value_id, GetJsonValue<int32_t>(json, kValueId));
ICEBERG_ASSIGN_OR_RAISE(auto value_required, GetJsonValue<bool>(json, kValueRequired));

ICEBERG_RETURN_UNEXPECTED(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe we can restrict key_type can't be unknown here, then we don't need to call ValidateUnknownFieldOptional for key_type.

@wgtmac wgtmac added the awaiting author action Author needs to address comments, resolve conflicts, answer questions, etc. label May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting author action Author needs to address comments, resolve conflicts, answer questions, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support v3 unknown data type

3 participants