Skip to content

GH-50915: [FORMAT] Allow TIMESTAMP logical type to annotate FIXED_LEN_BYTE_ARRAY(12) - #50916

Merged
pitrou merged 13 commits into
apache:mainfrom
divjotarora:flba-12
Sep 28, 2026
Merged

pitrou merged 13 commits into
apache:mainfrom
divjotarora:flba-12

Conversation

@divjotarora

@divjotarora divjotarora commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Rationale for this change

See apache/parquet-format#600 for rationale.

What changes are included in this PR?

This PR adds support for using TimestampType to annotate FIXED_LEN_BYTE_ARRAY(12) values. It also adds functionality to convert FLBA(12) values to Arrow INT64 timestamps with the following flags/logic to handle overflow:

  1. The conversion is guarded behind the convert_flba_timestamps property (default true). If false, conversion fails regardless of value.
  2. If the FLBA(12) value overflows max int64 or underflows min int64, the flba_timestamp_clamp_on_overflow property (default false) is consulted. If false, conversion fails. If true, the value is clamped to min/max int64.

Are these changes tested?

Yes, via unit tests and an e2e test that reads the file added in parquet-testing (apache/parquet-testing#123).

Are there any user-facing changes?

No

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #50915 has been automatically assigned in GitHub to PR creator.

Comment thread cpp/src/parquet/arrow/schema_internal.cc
Comment thread cpp/src/parquet/reader_test.cc
Comment thread cpp/src/parquet/statistics.cc Outdated

@emkornfield emkornfield left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some questions and comments I think the biggest one is scope and whether we should have an option to convert this value to a proper arrow type. Wemight also want to make it configurable the target of the arrow type

@github-actions github-actions Bot added the awaiting review Awaiting review label Aug 20, 2026
Comment thread cpp/src/parquet/arrow/arrow_reader_writer_test.cc Outdated
@github-actions github-actions Bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Sep 3, 2026
Comment thread cpp/src/parquet/arrow/reader_internal.cc Outdated
Comment thread cpp/src/parquet/arrow/reader_internal.cc Outdated
Comment thread cpp/src/parquet/arrow/schema_internal.cc Outdated
Comment thread cpp/src/parquet/properties.h Outdated
Comment thread cpp/src/parquet/arrow/reader_internal.cc Outdated
Comment thread cpp/src/parquet/arrow/reader_internal.cc Outdated

@emkornfield emkornfield left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the conversion code always assumes a 1:1 mapping between arrow timestamp granularity and parquet granularity. I think in the common path when schema is inferred this is workable, but IIRC users can also supply there own schema (we should add test coverage for this path).

Comment thread cpp/src/parquet/properties.h Outdated
Comment thread cpp/src/parquet/properties.h Outdated
@divjotarora

Copy link
Copy Markdown
Contributor Author

I think the conversion code always assumes a 1:1 mapping between arrow timestamp granularity and parquet granularity. I think in the common path when schema is inferred this is workable, but IIRC users can also supply there own schema (we should add test coverage for this path).

There doesn't seem to be an API at this level to supply a custom schema. The Arrow timestamp unit is derived from the Parquet logical type during schema conversion and that's passed down to the data converters. Based on this, I don't think any scaling is needed in this PR. To ensure correctness, I added a defensive check that fails the conversion if the Arrow and Parquet units differ.

Comment thread cpp/src/parquet/arrow/reader_internal.cc Outdated
Comment thread cpp/src/parquet/arrow/reader_internal.cc Outdated
@emkornfield

Copy link
Copy Markdown
Contributor

@github-actions crossbow submit

@github-actions

Copy link
Copy Markdown
no tasks were provided for the job
The Archery job run can be found at: https://github.com/apache/arrow/actions/runs/35890072900

Comment thread cpp/src/parquet/arrow/reader_internal.cc
@emkornfield

Copy link
Copy Markdown
Contributor

CI is green and changes look reasonale to me. I'll plan to merge Monday unless there are additional concerns raised.

Comment thread cpp/src/parquet/arrow/reader_internal.cc Outdated
Comment thread cpp/src/parquet/arrow/reader_internal.cc Outdated
Comment thread cpp/src/parquet/arrow/reader_internal.cc Outdated
Comment thread cpp/src/parquet/arrow/reader_internal.cc Outdated
Comment thread cpp/src/parquet/arrow/arrow_reader_writer_test.cc
Comment thread cpp/src/parquet/arrow/arrow_reader_writer_test.cc Outdated
Comment thread cpp/src/parquet/arrow/arrow_reader_writer_test.cc Outdated
Comment thread cpp/src/parquet/arrow/arrow_reader_writer_test.cc Outdated
Comment thread cpp/src/parquet/arrow/arrow_reader_writer_test.cc
@divjotarora
divjotarora requested a review from pitrou September 28, 2026 13:47
@divjotarora

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback @pitrou, this is ready for another look

Comment thread cpp/src/parquet/arrow/reader_internal.cc Outdated
Comment thread cpp/src/parquet/arrow/reader_internal.cc Outdated
Comment thread cpp/src/parquet/arrow/schema_internal.cc Outdated
@divjotarora
divjotarora requested a review from pitrou September 28, 2026 14:13

@pitrou pitrou 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.

LGTM now, thank you @divjotarora !

@pitrou

pitrou commented Sep 28, 2026

Copy link
Copy Markdown
Member

@github-actions crossbow submit -g cpp

@github-actions

Copy link
Copy Markdown

Revision: ad03173

Submitted crossbow builds: ursacomputing/crossbow @ actions-183bfb69cc

Task Status
example-cpp-minimal-build-static GitHub Actions
example-cpp-minimal-build-static-system-dependency GitHub Actions
example-cpp-tutorial GitHub Actions
test-build-cpp-fuzz GitHub Actions
test-conda-cpp GitHub Actions
test-conda-cpp-valgrind GitHub Actions
test-debian-13-cpp-amd64 GitHub Actions
test-debian-13-cpp-i386 GitHub Actions
test-debian-experimental-cpp-gcc-15 GitHub Actions
test-fedora-42-cpp GitHub Actions
test-ubuntu-22.04-cpp GitHub Actions
test-ubuntu-22.04-cpp-bundled GitHub Actions
test-ubuntu-22.04-cpp-emscripten GitHub Actions
test-ubuntu-22.04-cpp-no-threading GitHub Actions
test-ubuntu-24.04-cpp GitHub Actions
test-ubuntu-24.04-cpp-gcc-13-bundled GitHub Actions
test-ubuntu-24.04-cpp-gcc-14 GitHub Actions
test-ubuntu-24.04-cpp-minimal-with-formats GitHub Actions
test-ubuntu-24.04-cpp-thread-sanitizer GitHub Actions

@divjotarora

Copy link
Copy Markdown
Contributor Author

@emkornfield @pitrou The failure in C GLib & Ruby / ARM64 macOS GLib & Ruby (pull_request) seem to be unrelated to my changes, is this expected?

/Users/runner/work/arrow/arrow/build/cpp/_deps/google_cloud_cpp-src/google/cloud/internal/openssl/parse_service_account_p12_file.cc
/Users/runner/work/arrow/arrow/build/cpp/_deps/google_cloud_cpp-src/google/cloud/internal/openssl/parse_service_account_p12_file.cc:88:14: error: cannot initialize a variable of type 'X509_NAME *' (aka 'X509_name_st *') with an rvalue of type 'const X509_NAME *' (aka 'const X509_name_st *')
   88 |   X509_NAME* name = X509_get_subject_name(cert.get());
      |              ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
[113/662] Building CXX object _deps/google_cloud_cpp-build/google/cloud/storage/CMakeFiles/google_cloud_cpp_storage.dir/auto_finalize.cc.o

@pitrou

pitrou commented Sep 28, 2026

Copy link
Copy Markdown
Member

@emkornfield @pitrou The failure in C GLib & Ruby / ARM64 macOS GLib & Ruby (pull_request) seem to be unrelated to my changes, is this expected?

I would not say it's "expected" but you are certainly not responsible for it :) No worries!

@pitrou

pitrou commented Sep 28, 2026

Copy link
Copy Markdown
Member

The 32-bit build above is green (test-debian-13-cpp-i386), which is what I wanted to check. I'll merge now.

@pitrou
pitrou merged commit 464ae94 into apache:main Sep 28, 2026
56 of 57 checks passed
@pitrou

pitrou commented Sep 28, 2026

Copy link
Copy Markdown
Member

Gasp, I forgot to replace the [Format] in the PR title :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants