Skip to content

fix(manifest): round-trip decimal partition values - #998

Open
manuzhang wants to merge 1 commit into
apache:mainfrom
manuzhang:codex/fix-decimal-manifest-partitions
Open

manuzhang wants to merge 1 commit into
apache:mainfrom
manuzhang:codex/fix-decimal-manifest-partitions

Conversation

@manuzhang

Copy link
Copy Markdown
Member

Writing a manifest with non-null decimal partition values fails with nanoarrow EINVAL, and reading decimal partitions fails with Unsupported type decimal128 for partition values. Use a typed decimal128 append helper in the manifest adapter and decode decimal128 values with the partition field's precision and scale in the reader.

Add a manifest round-trip regression for format versions 1, 2, and 3 covering positive, negative, zero, null, and values larger than 64 bits. These shared fixes are extracted from #876 so decimal support can be reviewed independently of the metadata tables.

Validation:

  • The regression fails on unchanged main with write errors in all three versions; applying only the writer fix exposes the unsupported decimal reader error in all three versions.
  • With both fixes, the full manifest_test suite passes: 210 passed, 18 skipped.
  • Pre-commit and git diff --check pass.

Co-authored-by: Codex <codex@openai.com>
Copilot AI balanced review requested due to automatic review settings October 10, 2026 15:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused implementation correctly handles decimal128 values and includes comprehensive regression coverage.

0 open findings

What changed in this PR

Adds decimal partition-value support to manifest serialization and deserialization.

Changes:

  • Adds a typed nanoarrow decimal128 append helper.
  • Decodes decimal128 partition values with their declared precision and scale.
  • Tests positive, negative, zero, null, and >64-bit values across manifest versions 1–3.
File Description
src/​iceberg/​arrow_row_builder.cc Implements decimal128 appending.
src/​iceberg/​arrow_row_builder_internal.h Declares the decimal helper.
src/​iceberg/​manifest/​manifest_adapter.cc Uses typed decimal serialization.
src/​iceberg/​manifest/​manifest_reader.cc Decodes decimal128 partition values.
src/​iceberg/​test/​manifest_reader_test.cc Adds cross-version round-trip coverage.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@manuzhang
manuzhang requested review from wgtmac and zhjwpku October 10, 2026 16:08
ArrowDecimalInit(&value, Decimal::kBitWidth, type.precision(), type.scale());
ArrowArrayViewGetDecimalUnsafe(view, row_idx, &value);
int128_t unscaled;
std::memcpy(&unscaled, value.words, sizeof(unscaled));

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.

Does it work on big-endian machines? I'm not familiar with arrow's endianness, but I think we should double check.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks junwang for raising the question. Yes, it's a real issue. I also asked AI to carry out a thorough audit of the whole project and find similar issues in several places. Please check out #1000. cc @wgtmac

This branch has not been deployed

No deployments
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.

3 participants