Repository navigation
[feature](be) Add ORC reader for format v2 - #65183
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
There was a problem hiding this comment.
Pull request overview
This PR introduces ORC support in the BE format v2 scan path by adding a new format_v2::orc::OrcReader (with stripe pruning + ORC SearchArgument pushdown) and the supporting predicate-literal plumbing needed to lower Doris predicates into ORC SARGs.
Changes:
- Add a new format-v2 ORC
FileReaderimplementation plus ORC SearchArgument lowering (format_v2/orc/*). - Wire
FileFormat::ORCintoTableReader::create_file_reader, and extend Hive format-v2 mapping to support ORC positional schema mapping when name mapping is disabled. - Extend comparison / IN-list predicates to expose literal values + decimal scale/precision metadata for ORC SARG + statistics pruning.
Review Checkpoints (per skill guidance)
- Goal & completeness: The code path wiring and major building blocks (reader + SARG lowering + predicate literal accessors + Hive positional mapping) are present.
- Concurrency: No new explicit multi-threading/locking is introduced; the ORC lazy callback is invoked within the ORC reader flow, consistent with the existing ORC reader pattern.
- Lifecycle / invariants:
OrcReaderScanStatereset-on-close is clear; however, the current lazy callback row-position base tracking appears incorrect and can break correctness (see stored PR comment). - Tests: At least one unit test is added for Hive ORC positional mapping behavior; additional ORC reader tests mentioned in the PR description should be verified in CI.
Reviewed changes
Copilot reviewed 14 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| be/src/format_v2/table_reader.cpp | Instantiates the new ORC reader when _format == FileFormat::ORC. |
| be/src/format_v2/table/hive_reader.cpp | Enables ORC positional mapping based on hive_orc_use_column_names. |
| be/test/format_v2/table/hive_reader_test.cpp | Adds coverage for ORC positional mapping consumption of column_idxs. |
| be/src/format_v2/orc/orc_reader.h | Declares the new ORC format-v2 FileReader implementation. |
| be/src/format_v2/orc/orc_reader.cpp | Implements ORC reading, projection, stripe pruning, SARG pushdown, and lazy callback filtering. |
| be/src/format_v2/orc/orc_search_argument.h | Declares ORC SearchArgument lowering helpers. |
| be/src/format_v2/orc/orc_search_argument.cpp | Implements conservative lowering from localized predicates to ORC SARGs. |
| be/src/storage/predicate/predicate_literal_provider.h | Adds a small interface for extracting predicate literal(s) + decimal type info. |
| be/src/storage/predicate/comparison_predicate.h | Implements literal extraction for comparison predicates (incl. decimal type info). |
| be/src/storage/predicate/in_list_predicate.h | Implements literal list extraction for IN/NOT IN predicates (incl. decimal type info). |
| be/src/storage/predicate/predicate_creator_comparison.cpp | Propagates decimal precision/scale into comparison predicates. |
| be/src/storage/predicate/predicate_creator_in_list_in.cpp | Propagates precision/scale into IN-list predicates. |
| be/src/storage/predicate/predicate_creator_in_list_not_in.cpp | Propagates precision/scale into NOT-IN-list predicates. |
| be/src/format_v2/file_reader.h | Adds ORC lazy-filter stats field + exposes reader_statistics(). |
| be/src/format_v2/column_mapper.h | Comment-only clarification about filter localization fallback. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| _state->orc_lazy_selected_rows.clear(); | ||
| _state->orc_lazy_input_rows = 0; | ||
| _state->orc_lazy_next_batch_first_row = _state->row_reader->getRowNumber() + 1; | ||
| // ORC 库 next() 内部如果开了 lazy,会回调 _filter_orc_batch | ||
| has_next = _state->row_reader->next(*_state->batch); |
There was a problem hiding this comment.
Fixed in 192131b. _state->orc_lazy_next_batch_first_row is now initialized once when the ORC RowReader is created, and _filter_orc_batch() is the only place that advances it by callback batch size. Added a cross-batch delete predicate test to cover __file_row_position correctness.
| filter_block.reserve(_request->local_positions.size()); | ||
| for (size_t position = 0; position < _request->local_positions.size(); ++position) { | ||
| const auto local_position = format::LocalIndex(position); | ||
| const auto entry_it = std::ranges::find_if( | ||
| _request->local_positions, | ||
| [&](const auto& entry) { return entry.second == local_position; }); | ||
| if (entry_it == _request->local_positions.end()) { | ||
| return Status::InvalidArgument("ORC scan local positions are not dense at {}", | ||
| position); | ||
| } |
There was a problem hiding this comment.
Fixed in 192131b. The lazy callback now builds a dense position_to_column vector once and uses direct indexing; it also keeps out-of-range, duplicate, and non-dense local-position validation.
TPC-H: Total hot run time: 29605 ms |
4cadb4a to
010fb7e
Compare
TPC-DS: Total hot run time: 173604 ms |
ClickBench: Total hot run time: 25.24 s |
|
run buildall |
|
run buildall |
TPC-H: Total hot run time: 29868 ms |
TPC-DS: Total hot run time: 173183 ms |
ClickBench: Total hot run time: 25.25 s |
|
run buildall |
TPC-H: Total hot run time: 29493 ms |
TPC-DS: Total hot run time: 172876 ms |
ClickBench: Total hot run time: 25.24 s |
|
run buildall |
TPC-H: Total hot run time: 29610 ms |
TPC-DS: Total hot run time: 173587 ms |
ClickBench: Total hot run time: 25.85 s |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
|
run buildall |
### What problem does this PR solve? Issue Number: None Related PR: apache#65183 Problem Summary: ORC v2 previously depended on an ORC callback API extension to know the batch first row while filtering lazy predicate columns. That made the PR carry an apache-orc submodule pointer change. Align ORC v2 with the existing ORC callback API by keeping virtual row predicate columns out of the callback path and marking condition cache rows after nextBatch() returns, when row_reader->getRowNumber() exposes the real batch start. Also restore the v1 ORC callback signature and rewind the apache-orc submodule pointer so the main PR no longer depends on thirdparty ORC changes. ### Release note None ### Check List (For Author) - Test: Unit Test - User reported local BE UT/build for the ORC lazy row handling change passed. - Behavior changed: No - Does this need documentation: No
### What problem does this PR solve? Issue Number: None Related PR: apache#65183 Problem Summary: ORC v2 reader owned the ORC type switch for materializing decoded batches into Doris columns, including scalar values, timestamp values, and complex child recursion. That kept file-format decoding details in OrcReader even though decoded value materialization belongs to the SerDe layer. Add an ORC decoded batch view and a DataTypeSerDe::read_column_from_orc entry point that owns the ORC-to-Doris materialization, then make OrcReader construct the view and call the unified SerDe interface. ### Release note None ### Check List (For Author) - Test: Unit Test - build-support/clang-format.sh be/src/core/data_type_serde/data_type_serde.cpp be/src/core/data_type_serde/data_type_serde.h be/src/format_v2/orc/orc_reader.cpp be/src/format_v2/orc/orc_reader.h - git diff --check - ninja -C be/ut_build_ASAN -j12 src/core/CMakeFiles/Core.dir/data_type_serde/data_type_serde.cpp.o src/format/CMakeFiles/Format.dir/__/format_v2/orc/orc_reader.cpp.o - ninja -C be/ut_build_ASAN -j12 test/CMakeFiles/doris_be_test.dir/format_v2/orc/orc_reader_test.cpp.o - Behavior changed: No - Does this need documentation: No
### What problem does this PR solve? Issue Number: close #xxx Related PR: apache#65183 Problem Summary: ORC scanner v2 still built an ORC SearchArgument from local conjuncts when enable_orc_filter_by_min_max was disabled. That let ORC evaluate row group statistics and publish non-zero EvaluatedRowGroupCount/SelectedRowGroupCount, which violates the session variable semantics and breaks test_orc_lazy_mat_profile. The fix records the session variable in the ORC v2 scan state and skips SARG initialization when min/max filtering is disabled, matching the existing v1 reader behavior. A regression unit test covers the disabled min/max profile counters. ### Release note None ### Check List (For Author) - Test: Unit Test / Manual test - build-support/clang-format.sh be/src/format_v2/orc/orc_reader.cpp be/test/format_v2/orc/orc_reader_test.cpp - git diff --check - ninja -C be/ut_build_ASAN -j12 src/format/CMakeFiles/Format.dir/__/format_v2/orc/orc_reader.cpp.o test/CMakeFiles/doris_be_test.dir/format_v2/orc/orc_reader_test.cpp.o - Full doris_be_test relink was not completed because it would rebuild 1495 targets in this worktree. - Behavior changed: No - Does this need documentation: No
|
run buildall |
### What problem does this PR solve? Issue Number: None Related PR: apache#65183 Problem Summary: The previous ORC v2 decode refactor moved the ORC type switch from OrcReader into DataTypeSerDe::read_column_from_orc, but that still kept centralized type dispatch in the base SerDe. This change follows the existing read_column_from_decoded_values pattern: the base SerDe keeps only the default unsupported implementation, while nullable, number, string, decimal, date, timestamp, and complex SerDes override read_column_from_orc and own their Doris-type-specific materialization. OrcReader now only builds OrcDecodedColumnView and calls the column SerDe. ### Release note None ### Check List (For Author) - Test: Unit Test / Manual test - build-support/clang-format.sh be/src/core/data_type_serde/data_type_serde.cpp be/src/core/data_type_serde/data_type_serde.h be/src/core/data_type_serde/data_type_number_serde.h be/src/core/data_type_serde/data_type_string_serde.h be/src/core/data_type_serde/data_type_decimal_serde.h be/src/core/data_type_serde/data_type_nullable_serde.h be/src/core/data_type_serde/data_type_array_serde.h be/src/core/data_type_serde/data_type_map_serde.h be/src/core/data_type_serde/data_type_struct_serde.h be/src/core/data_type_serde/data_type_datev2_serde.h be/src/core/data_type_serde/data_type_datetimev2_serde.h be/src/core/data_type_serde/data_type_timestamptz_serde.h be/src/format_v2/orc/orc_reader.cpp - git diff --check - ninja -C be/ut_build_ASAN -j12 src/core/CMakeFiles/Core.dir/data_type_serde/data_type_serde.cpp.o src/format/CMakeFiles/Format.dir/__/format_v2/orc/orc_reader.cpp.o test/CMakeFiles/doris_be_test.dir/format_v2/orc/orc_reader_test.cpp.o - rg -n "switch \(view\.file_type->getKind\)|read_column_from_orc\(const DataTypePtr|read_column_from_orc\(column_type" be/src/core/data_type_serde be/src/format_v2/orc/orc_reader.cpp - Behavior changed: No - Does this need documentation: No
### What problem does this PR solve? Issue Number: None Related PR: apache#65183 Problem Summary: The format v2 ORC reader exposed two RuntimeProfile counters, FilteredRowsByLazyRead and FilteredRowsByOrcLazyRead, backed by the same lazy-read filtered row statistic. This duplicated profile output without adding a distinct metric. Keep the existing shared FilteredRowsByLazyRead counter used by ORC/Parquet lazy materialization and remove the ORC-only duplicate counter. Also align the row-position delete predicate unit test with the current lazy callback semantics: predicates that depend only on the virtual row-position column do not use ORC lazy callback filtering. ### Release note None ### Check List (For Author) - Test: Unit Test - Ran git diff --check - Ran ninja -C be/ut_build_ASAN -j12 src/format/CMakeFiles/Format.dir/__/format_v2/orc/orc_reader.cpp.o test/CMakeFiles/doris_be_test.dir/format_v2/orc/orc_reader_test.cpp.o - Behavior changed: No - Does this need documentation: No
|
run buildall |
TPC-H: Total hot run time: 29865 ms |
TPC-DS: Total hot run time: 180387 ms |
ClickBench: Total hot run time: 24.89 s |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
|
/review |
There was a problem hiding this comment.
Requesting changes for one test-validity issue in the new ORC v2 timezone coverage.
Checkpoint conclusions:
- Goal/behavior: non-hour offset session timezone support is still not proven because the new test can pass even when
reader->open()fails for+05:30. - Scope/duplicates: existing threads cover the broader timezone question; this inline comment is distinct because it targets the newly added assertion on the test line.
- Session/config behavior: this is the affected area; the test should prove the session timezone is accepted and used end to end.
- Compatibility/persistence: no storage metadata or replay compatibility issue found in the touched code.
- Lifecycle/concurrency: no new lifecycle or threading issue found in the reviewed paths.
- Tests: broad ORC v2 coverage was added, but this specific regression must assert success, and preferably read timestamp/timestamp-instant data under
+05:30. - Validation: static review only. This checkout is missing
.worktree_initialized,thirdparty/installed, andthirdparty/installed/bin/protoc, so I did not run local builds or tests.
Subagent conclusions: optimizer-rewrite and tests-session-config both reviewed the final ledger/comment set and returned NO_NEW_VALUABLE_FINDINGS.
## Summary Backport the FileScannerV2 / format_v2 series to `branch-4.1` in the requested order. - Includes 28 unique source PRs, including #65502. - FileScannerV2 and format_v2 use their native implementations. - #62306 is intentionally not cherry-picked. FileScannerV2 and format_v2 do not depend on it; the V1 behavior required by this series is adapted manually on top of the existing branch-4.1 code. - The V1 adaptations cover TopN validation, deletion-vector handling, runtime-filter cloning/type semantics, JNI cleanup retry, Paimon IOManager/metrics, text-reader fixes, and the branch-4.1 expression API used by equality-delete predicates. - Native format_v2 JDBC and Iceberg system-table paths remain on the branch-4.1 legacy/unsupported routing because the newer thrift split protocols are not present on this branch. ## Source PRs #65046, #65130, #65151, #65175, #65194, #65218, #65281, #65326, #65328, #65332, #65354, #65094, #65351, #65359, #65370, #65183, #65369, #65449, #65437, #65451, #65475, #65495, #65496, #65501, #65500, #65478, #65503, #65502. ## Branch-specific fixes - Adapted #65502 to the branch-4.1 expression selector API and fixed the associated FE checkstyle issues. - Fixed TeamCity External Regression 994576 and P0/CloudP0 995015/995017: schema discovery does not create a `RuntimeState`, so V1 CSV, JSON, Native, ORC, and Parquet readers now fall back to default `TQueryOptions` instead of dereferencing a null state. - Fixed TeamCity BE UT 994856, which crashed in the same V1 ORC reader-options path. - Restored only the small V1 schema-reader fallback required on branch-4.1; #62306 remains intentionally excluded. - Added null-`RuntimeState` regression coverage for CSV and Native schema discovery. - Initialized the format_v2 ORC test suite timezone cache once at suite setup, covering session-timezone and DST timestamp assertions that become reachable after the V1 ORC core is fixed. ## Validation - Full ASAN `doris_be_test` build compiled and linked successfully; the post-#65502 incremental verification completed 1,091/1,091 build targets. - 313/313 focused BE tests passed across FileScannerV2, TableReader, ColumnMapper, condition cache, deletion vectors/predicates, JNI, Hive/Paimon/Iceberg readers, zonemap filtering, and casts. - The latest ASAN verification passed 232/232 focused Iceberg reader, equality-delete, ColumnMapper, and TableReader tests. - 215/215 affected reader tests passed across V1 CSV/JSON/Native/ORC/Parquet and format_v2 ORC/Parquet, including the TeamCity ORC core reproducer. - The three format_v2 ORC session-timezone assertions passed 3/3 under ASAN. - 88/88 original focused FE tests passed; the post-#65502 FE verification passed an additional 40/40 tests covering ExternalUtil and Iceberg planning/utilities. - 10/10 `PaimonJniScannerTest` tests passed. - Maven reactor completed with `BUILD SUCCESS`; checkstyle reported 0 violations. - `build-support/check-format.sh` passed across 4,136 files. --------- Co-authored-by: Chenjunwei <138805230+xylaaaaa@users.noreply.github.com>
### Background Doris translates supported ORC scan predicates into search arguments. The ORC library uses file statistics and Bloom filters to skip stripes or row groups before Doris evaluates SQL predicates on the remaining rows. ### What problem does this PR solve? Issue Number: None Related PR: #65183 (introduced the current SARG builder; the legacy path was already affected) PR Type: Bugfix Problem Summary: ORC scans with floating-point Bloom filters can omit matching rows when a zero predicate and stored zeros have opposite signs. This change probes both zero bit patterns in one IN leaf so pruning preserves SQL's equality of positive and negative zero. Most of the diff adds real-file unit and SQL regression coverage. For the checked-in row-group fixture, a count with `WHERE d = 0.0` and SARG enabled produced: | Before | After | Expected | | --- | --- | --- | | 1000 | 2000 | 2000 | ### Details - **Change map:** Production code +22/-11; tests and fixture generator +403/-0; generated regression output +13/-0; documentation +0/-0. Two ORC fixtures total 132,252 bytes. Tests account for most of the change. - **Frequency:** Always in the reproduced layout: zero signs occupy different Bloom filters, and pruning probes only the opposite sign. It affects FLOAT and DOUBLE equality, null-safe equality and IN predicates. - **Root cause:** ORC Bloom filters hash the raw floating-point bits, while SQL equates both signs of zero. The SARG builder previously supplied only the literal's sign, allowing a matching group to be rejected before row filtering. - **Why existing tests missed it:** `NewOrcReaderTest.SargFloatWideningCastConjunctPrunesStripes` covers floating ranges without signed-zero Bloom filters, while the binary Bloom tests cover strings. The closest SQL suite, `test_orc_condition_cache_seek`, covers integer seek/cache behavior. Neither layer tests opposite-sign zero groups. The new SQL suite is in the External pipeline's `p0,external` group. - **Fix:** Normalize zero equality and IN candidates at the shared Doris SARG adapter by adding the opposite sign to one IN leaf. ORC merges separate equality leaves for the two signs, so an OR of equalities would still be unsafe. Nonzero equality and IN Bloom pruning remain covered. - **Other paths and branches:** This fixes the native ORC SARG path shared by TVFs and catalogs on master. Parquet uses a separate implementation. Static checks found the same defect in branch-3.1, branch-4.0, branch-4.1 and branch-4.2; those need separate backports, including legacy reader paths where present. Release branches were not dynamically tested. #65183 introduced the current builder, not the original defect. ### Testing - Locally ran 20 new parameterized real-ORC tests across FLOAT/DOUBLE and row-group/stripe layouts. Before the fix, 12 equality/IN tests failed and eight controls passed; after it, all 20 passed. Together with the existing `NewOrcReaderTest` suite, all 217 ASAN tests passed. - Locally ran `run-regression-test.sh --run -d external_table_p0/tvf -s test_orc_signed_zero_bloom`, after generating output through the runner. All 336 complete ordered-ID comparisons passed with SARG and lazy materialization each on/off, both column widths and both layouts; one suite, zero failures and zero skips. The baseline failed by losing the negative-zero IDs. - Regenerated both fixtures byte-for-byte and independently decoded their zero signs, NULLs and stripe layouts with PyArrow. ### Notes for Reviewers SQL regression ran against a disposable local S3 emulator. Provider-specific remote S3 and Azure uploads were not exercised locally; the suite follows the existing provider-aware upload and cleanup pattern. ### Release note Fix missing rows in ORC scans when floating-point Bloom pruning encounters equality or IN predicates involving positive and negative zero. ### Check List (For Author) - Behavior changed: No - Does this need documentation: No - Pre-submission status: Ready ### AI Disclosure - Tool: Codex (GPT-6) - Generated: Code, unit tests, regression tests, fixture generator and this description. - Human review: Not stated by the author.
### Background Doris translates supported ORC scan predicates into search arguments. The ORC library uses file statistics and Bloom filters to skip stripes or row groups before Doris evaluates SQL predicates on the remaining rows. ### What problem does this PR solve? Issue Number: None Related PR: #65183 (introduced the current SARG builder; the legacy path was already affected) PR Type: Bugfix Problem Summary: ORC scans with floating-point Bloom filters can omit matching rows when a zero predicate and stored zeros have opposite signs. This change probes both zero bit patterns in one IN leaf so pruning preserves SQL's equality of positive and negative zero. Most of the diff adds real-file unit and SQL regression coverage. For the checked-in row-group fixture, a count with `WHERE d = 0.0` and SARG enabled produced: | Before | After | Expected | | --- | --- | --- | | 1000 | 2000 | 2000 | ### Details - **Change map:** Production code +22/-11; tests and fixture generator +403/-0; generated regression output +13/-0; documentation +0/-0. Two ORC fixtures total 132,252 bytes. Tests account for most of the change. - **Frequency:** Always in the reproduced layout: zero signs occupy different Bloom filters, and pruning probes only the opposite sign. It affects FLOAT and DOUBLE equality, null-safe equality and IN predicates. - **Root cause:** ORC Bloom filters hash the raw floating-point bits, while SQL equates both signs of zero. The SARG builder previously supplied only the literal's sign, allowing a matching group to be rejected before row filtering. - **Why existing tests missed it:** `NewOrcReaderTest.SargFloatWideningCastConjunctPrunesStripes` covers floating ranges without signed-zero Bloom filters, while the binary Bloom tests cover strings. The closest SQL suite, `test_orc_condition_cache_seek`, covers integer seek/cache behavior. Neither layer tests opposite-sign zero groups. The new SQL suite is in the External pipeline's `p0,external` group. - **Fix:** Normalize zero equality and IN candidates at the shared Doris SARG adapter by adding the opposite sign to one IN leaf. ORC merges separate equality leaves for the two signs, so an OR of equalities would still be unsafe. Nonzero equality and IN Bloom pruning remain covered. - **Other paths and branches:** This fixes the native ORC SARG path shared by TVFs and catalogs on master. Parquet uses a separate implementation. Static checks found the same defect in branch-3.1, branch-4.0, branch-4.1 and branch-4.2; those need separate backports, including legacy reader paths where present. Release branches were not dynamically tested. #65183 introduced the current builder, not the original defect. ### Testing - Locally ran 20 new parameterized real-ORC tests across FLOAT/DOUBLE and row-group/stripe layouts. Before the fix, 12 equality/IN tests failed and eight controls passed; after it, all 20 passed. Together with the existing `NewOrcReaderTest` suite, all 217 ASAN tests passed. - Locally ran `run-regression-test.sh --run -d external_table_p0/tvf -s test_orc_signed_zero_bloom`, after generating output through the runner. All 336 complete ordered-ID comparisons passed with SARG and lazy materialization each on/off, both column widths and both layouts; one suite, zero failures and zero skips. The baseline failed by losing the negative-zero IDs. - Regenerated both fixtures byte-for-byte and independently decoded their zero signs, NULLs and stripe layouts with PyArrow. ### Notes for Reviewers SQL regression ran against a disposable local S3 emulator. Provider-specific remote S3 and Azure uploads were not exercised locally; the suite follows the existing provider-aware upload and cleanup pattern. ### Release note Fix missing rows in ORC scans when floating-point Bloom pruning encounters equality or IN predicates involving positive and negative zero. ### Check List (For Author) - Behavior changed: No - Does this need documentation: No - Pre-submission status: Ready ### AI Disclosure - Tool: Codex (GPT-6) - Generated: Code, unit tests, regression tests, fixture generator and this description. - Human review: Not stated by the author.
…be hidden ### Background The native ORC reader can answer MIN/MAX from selected stripe statistics instead of decoding rows. ORC floating statistics also contain an optional sum, which standard writers make NaN when a stripe contains a NaN. ### What problem does this PR solve? Issue Number: None Related PR: apache#65183 (introduced native ORC metadata aggregates), apache#65559 (4.1 backport) PR Type: Bugfix Problem Summary: An ORC stripe containing `[1, NaN, 2]` can expose finite bounds, so metadata aggregation returns `2` while an ordinary scan returns `NaN`. Require an available, finite sum before trusting floating bounds and otherwise use the existing row-scan fallback. Most of the diff adds tests for the fallback and the finite-value optimization. | FLOAT and DOUBLE values | MAX before | MAX after / ordinary scan | |---|---|---| | `1, NaN, 2` | `2` | `NaN` | ### Details - **Change map:** Production code +4/-1 lines; tests +649/-3; generated regression output +85/-0; no documentation changes. The production change is one statistics eligibility guard; the tests author standard ORC files and exercise reader fallback, selected stripes and SQL aggregates. - **Frequency:** Always when native MIN/MAX uses finite floating bounds from a selected stripe whose values contain a hidden NaN; reproduced with both FLOAT and DOUBLE using standard writers. - **Root cause:** `set_floating_zone_map` accepted minimum and maximum without checking the sum. A writer can keep finite endpoints after observing a NaN, so those endpoints do not preserve row aggregation semantics. - **Why existing tests missed it:** Existing `NewOrcReaderTest.AggregatePushdown*` tests cover primitive and nested bounds, stripe selection, timestamps and COUNT without floating NaNs. Iceberg regressions such as `test_iceberg_orc_decimal_bounds` check decimal metadata rather than floating MIN/MAX; fuzzy floating comparisons can also miss a NaN mismatch. New SQL tests compare strings and NaN flags explicitly. - **Fix:** Reject missing or non-finite floating sums at native metadata conversion. This conservatively scans infinities and sum overflows as well, while finite sums retain metadata aggregation. COUNT, integer bounds and ordinary ORC predicate pruning retain their existing behavior. - **Other paths and branches:** The conversion is shared by native ORC catalog scans, including Iceberg and Hive. It has one aggregate call site; ordinary ORC SARG pruning uses the SDK separately. Parquet metadata aggregation uses a separate implementation. Static inspection finds the same unchecked guard in branch-4.1 and branch-4.2; branch-3.1 and branch-4.0 lack this native path. Release branches were not executed locally. ### Testing - Local ASAN: all 201 `NewOrcReaderTest` tests passed. Four new tests cover 24 floating-statistics inputs, real `TableReader` fallback without losing NaNs or rows, valid missing-sum compatibility files, and safe/unsafe stripe selection and pruning. The new cases fail against the original guard. - Local native SQL: `test_iceberg_orc_floating_minmax` fails before the fix (`2` versus `NaN`) and passes after it. Fourteen standard SDK fixtures cover NaN positions, NULLs, infinities, overflow, independent FLOAT/DOUBLE columns and empty tables. Generated output was independently checked against scan results and known fixture counts, then replayed normally. The final fixture launcher joins its output readers before checking SDK markers. - The fixture helper authored and read back all 14 cases with Iceberg 1.12 and the stock 1.10.1 runtime SDK. No data or statistics editing is used for the NaN reproduction. ### Notes for Reviewers The missing-sum unit fixture only renames an optional protobuf field while preserving bounds and data; it tests compatibility separately from standard-writer NaNs. The SQL suite supports an existing Spark/REST Docker environment or an explicitly configured local SDK/file warehouse. Docker deployment and automatic Docker CI execution were not verified locally. ### Release note Fix incorrect floating MIN/MAX results from ORC stripe metadata when a stripe contains NaN values. ### Check List (For Author) - Behavior changed: No - Does this need documentation: No - Pre-submission status: Partially verified: Docker deployment and automatic Docker CI execution are unverified; the same SQL suite passed on an owned local cluster ### AI Disclosure - Tool: Codex (GPT-6) - Generated: Code, unit tests, regression tests and this description - Human review: not stated
…be hidden (#70930) ### Background The native ORC reader can answer MIN/MAX from selected stripe statistics instead of decoding rows. ORC floating statistics also contain an optional sum, which standard writers make NaN when a stripe contains a NaN. ### What problem does this PR solve? Issue Number: None Related PR: #65183 (introduced native ORC metadata aggregates), #65559 (4.1 backport) PR Type: Bugfix Problem Summary: An ORC stripe containing `[1, NaN, 2]` can expose finite bounds, so metadata aggregation returns `2` while an ordinary scan returns `NaN`. Require an available, finite sum before trusting floating bounds and otherwise use the existing row-scan fallback. Most of the diff adds tests for the fallback and the finite-value optimization. | FLOAT and DOUBLE values | MAX before | MAX after / ordinary scan | |---|---|---| | `1, NaN, 2` | `2` | `NaN` | ### Details - **Change map:** Production code +4/-1 lines; tests +649/-2; generated regression output +85/-0; no documentation changes. The production change is one statistics eligibility guard; the tests author standard ORC files and exercise reader fallback, selected stripes and SQL aggregates. - **Frequency:** Always when native MIN/MAX uses finite floating bounds from a selected stripe whose values contain a hidden NaN; reproduced with both FLOAT and DOUBLE using standard writers. - **Root cause:** `set_floating_zone_map` accepted minimum and maximum without checking the sum. A writer can keep finite endpoints after observing a NaN, so those endpoints do not preserve row aggregation semantics. - **Why existing tests missed it:** Existing `NewOrcReaderTest.AggregatePushdown*` tests cover primitive and nested bounds, stripe selection, timestamps and COUNT without floating NaNs. Iceberg regressions such as `test_iceberg_orc_decimal_bounds` check decimal metadata rather than floating MIN/MAX; fuzzy floating comparisons can also miss a NaN mismatch. New SQL tests compare strings and NaN flags explicitly. - **Fix:** Reject missing or non-finite floating sums at native metadata conversion. This conservatively scans infinities and sum overflows as well, while finite sums retain metadata aggregation. COUNT, integer bounds and ordinary ORC predicate pruning retain their existing behavior. - **Other paths and branches:** The conversion is shared by native ORC catalog scans, including Iceberg and Hive. It has one aggregate call site; ordinary ORC SARG pruning uses the SDK separately. Parquet metadata aggregation uses a separate implementation. Static inspection finds the same unchecked guard in branch-4.1 and branch-4.2; branch-3.1 and branch-4.0 lack this native path. Release branches were not executed locally. ### Testing - Local ASAN: all 201 `NewOrcReaderTest` tests passed. Four new tests cover 24 floating-statistics inputs, real `TableReader` fallback without losing NaNs or rows, valid missing-sum compatibility files, and safe/unsafe stripe selection and pruning. The new cases fail against the original guard. - Local launcher reproduction: interpolated arguments trigger ArrayStoreException before normalization; literal arguments and child-command errors pass afterward. - Local native SQL: `test_iceberg_orc_floating_minmax` fails before the fix (`2` versus `NaN`) and passes after it. Fourteen standard SDK fixtures cover NaN positions, NULLs, infinities, overflow, independent FLOAT/DOUBLE columns and empty tables. Generated output was independently checked against scan results and known fixture counts, then replayed normally. The final fixture launcher joins its output readers before checking SDK markers. - The fixture helper authored and read back all 14 cases with Iceberg 1.12 and the stock 1.10.1 runtime SDK. No data or statistics editing is used for the NaN reproduction. ### Notes for Reviewers The missing-sum unit fixture only renames an optional protobuf field while preserving bounds and data; it tests compatibility separately from standard-writer NaNs. The SQL suite supports an existing Spark/REST Docker environment or an explicitly configured local SDK/file warehouse. Full Docker fixture execution after argument normalization awaits CI. ### Release note Fix incorrect floating MIN/MAX results from ORC stripe metadata when a stripe contains NaN values. ### Check List (For Author) - Behavior changed: No - Does this need documentation: No - Pre-submission status: Partially verified: full Docker fixture execution after argument normalization awaits CI; command-boundary checks and the SQL suite passed locally ### AI Disclosure - Tool: Codex (GPT-6) - Generated: Code, unit tests, regression tests and this description - Human review: not stated
…be hidden (#70930) ### Background The native ORC reader can answer MIN/MAX from selected stripe statistics instead of decoding rows. ORC floating statistics also contain an optional sum, which standard writers make NaN when a stripe contains a NaN. ### What problem does this PR solve? Issue Number: None Related PR: #65183 (introduced native ORC metadata aggregates), #65559 (4.1 backport) PR Type: Bugfix Problem Summary: An ORC stripe containing `[1, NaN, 2]` can expose finite bounds, so metadata aggregation returns `2` while an ordinary scan returns `NaN`. Require an available, finite sum before trusting floating bounds and otherwise use the existing row-scan fallback. Most of the diff adds tests for the fallback and the finite-value optimization. | FLOAT and DOUBLE values | MAX before | MAX after / ordinary scan | |---|---|---| | `1, NaN, 2` | `2` | `NaN` | ### Details - **Change map:** Production code +4/-1 lines; tests +649/-2; generated regression output +85/-0; no documentation changes. The production change is one statistics eligibility guard; the tests author standard ORC files and exercise reader fallback, selected stripes and SQL aggregates. - **Frequency:** Always when native MIN/MAX uses finite floating bounds from a selected stripe whose values contain a hidden NaN; reproduced with both FLOAT and DOUBLE using standard writers. - **Root cause:** `set_floating_zone_map` accepted minimum and maximum without checking the sum. A writer can keep finite endpoints after observing a NaN, so those endpoints do not preserve row aggregation semantics. - **Why existing tests missed it:** Existing `NewOrcReaderTest.AggregatePushdown*` tests cover primitive and nested bounds, stripe selection, timestamps and COUNT without floating NaNs. Iceberg regressions such as `test_iceberg_orc_decimal_bounds` check decimal metadata rather than floating MIN/MAX; fuzzy floating comparisons can also miss a NaN mismatch. New SQL tests compare strings and NaN flags explicitly. - **Fix:** Reject missing or non-finite floating sums at native metadata conversion. This conservatively scans infinities and sum overflows as well, while finite sums retain metadata aggregation. COUNT, integer bounds and ordinary ORC predicate pruning retain their existing behavior. - **Other paths and branches:** The conversion is shared by native ORC catalog scans, including Iceberg and Hive. It has one aggregate call site; ordinary ORC SARG pruning uses the SDK separately. Parquet metadata aggregation uses a separate implementation. Static inspection finds the same unchecked guard in branch-4.1 and branch-4.2; branch-3.1 and branch-4.0 lack this native path. Release branches were not executed locally. ### Testing - Local ASAN: all 201 `NewOrcReaderTest` tests passed. Four new tests cover 24 floating-statistics inputs, real `TableReader` fallback without losing NaNs or rows, valid missing-sum compatibility files, and safe/unsafe stripe selection and pruning. The new cases fail against the original guard. - Local launcher reproduction: interpolated arguments trigger ArrayStoreException before normalization; literal arguments and child-command errors pass afterward. - Local native SQL: `test_iceberg_orc_floating_minmax` fails before the fix (`2` versus `NaN`) and passes after it. Fourteen standard SDK fixtures cover NaN positions, NULLs, infinities, overflow, independent FLOAT/DOUBLE columns and empty tables. Generated output was independently checked against scan results and known fixture counts, then replayed normally. The final fixture launcher joins its output readers before checking SDK markers. - The fixture helper authored and read back all 14 cases with Iceberg 1.12 and the stock 1.10.1 runtime SDK. No data or statistics editing is used for the NaN reproduction. ### Notes for Reviewers The missing-sum unit fixture only renames an optional protobuf field while preserving bounds and data; it tests compatibility separately from standard-writer NaNs. The SQL suite supports an existing Spark/REST Docker environment or an explicitly configured local SDK/file warehouse. Full Docker fixture execution after argument normalization awaits CI. ### Release note Fix incorrect floating MIN/MAX results from ORC stripe metadata when a stripe contains NaN values. ### Check List (For Author) - Behavior changed: No - Does this need documentation: No - Pre-submission status: Partially verified: full Docker fixture execution after argument normalization awaits CI; command-boundary checks and the SQL suite passed locally ### AI Disclosure - Tool: Codex (GPT-6) - Generated: Code, unit tests, regression tests and this description - Human review: not stated
What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
This PR adds ORC support to the format v2 file reader path.
format_v2/orc/OrcReaderand ORC SearchArgument lowering.FileFormat::ORCintoTableReader::create_file_reader.Release note
Add ORC reader support for file scanner v2.
Check List (For Author)
Manual verification:
rg -n "reader_expression_map|FileNestedPredicateTarget|FileStructPredicateTarget|child_id_path|column_filter\\.target|PredicateColumnType|predicate_column\\.h" be/src/format_v2 be/test/format_v2 be/src/storage/predicateThe following source groups were also checked with
clang++ -fsyntax-onlyusing the existing BE compile command flags:Full local CMake build could not be completed in this workspace because configure fails before generating
build.ninjaincontrib/openblas:Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)