Repository navigation
[fix](be) Preserve JSON and WAL rows with empty file projections - #70154
Conversation
### What problem does this PR solve? Issue Number: close apache#69926 Problem Summary: Preserve accepted JSON record counts independently of output columns so partition projections and aggregates receive the correct rows. Keep batch progress, JSON paths, error rollback, and malformed-record handling consistent, and add unit and Hive SQL regression coverage. ### Release note Fix incorrect zero counts and missing rows in partition-only Hive JSON scans. ### Check List (For Author) - Test: 151 ASAN unit tests passed; Hive SQL regression added and Groovy-compiled. - Behavior changed: Yes, zero file-column projections retain valid records. - Does this need documentation: No.
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
|
/review |
### What problem does this PR solve? Issue Number: close apache#69926 Related PR: apache#70154 Problem Summary: The WAL V2 reader counts rows from the projected output block, so an empty projection reports zero despite a nonempty source block. Save the source row count before materialization moves column ownership and keep the existing filter pipeline. Add eight writer-backed cases covering empty, single-column, and reordered full projections, multiple blocks, schema discovery, and repeated EOF reads. ### Release note Preserve logical row counts for empty WAL reader projections. ### Check List (For Author) - Test: 166 ASAN tests passed across JSON, TableReader, WAL V2, WAL reader/writer, and CSV/Text empty-projection controls. Both new empty WAL projection cases failed before the fix; six projection controls passed. - Behavior changed: Yes; empty WAL projections report source rows. - Does this need documentation: No.
|
run buildall |
|
/review |
There was a problem hiding this comment.
No actionable defects found in the six changed files at head 3f6f6f3dd6d512d325fa6e4f5a4a6726777778eb. The changes address lost logical rows when JSON or WAL file projections contain no columns. There are no existing inline findings to retain or duplicate, and no additional user-provided focus points.
Applicable critical checkpoints:
- Goal and evidence: JSON now counts accepted records independently of Block::rows(); WAL saves deserialized cardinality before moving columns. TableReader passes that explicit count into partition/default materialization. Added reader tests and a real TableReader partition test exercise this contract; test execution was not performed here.
- Scope and reuse: production changes are limited to the JSON reader/header and WAL reader. They reuse the existing mapper, materialization, and shared filtering pipeline.
- Concurrency: the new counter is reader-local and used by sequential scanner reads. No shared state, new threads, locks, lock-order changes, or work inside locks is introduced.
- Lifecycle and ownership: the counter resets per batch, accepted appends increment once, error rollback restores it with the columns, and filtering receives the explicit count. WAL captures rows before ownership transfer; schema discovery, final batches, repeated EOF, and close retain their existing lifecycle. No new cross-translation-unit static initialization dependency was found.
- Configuration: no configuration items or dynamic-update behavior are added.
- Compatibility: no storage encoding, WAL header, version check, serialized metadata, or public protocol changes are introduced. Existing populated and reordered projections retain their cardinality.
- Thrift/Protobuf: neither definition directory changes; field-ID compatibility checks are inapplicable.
- Parallel paths: simple objects, arrays, JSON roots/paths, malformed-null rows, load rejection, and nonempty projections were traced. CSV/Text already use independent row counts and retain equivalent empty-projection controls.
- Conditional checks: the new empty-request branch preserves JSON-path record selection; root and missing paths receive explicit handling. Ondemand cursor reuse and rollback were inspected. Unrequested-value validation remains projection-dependent, as in the existing reader.
- Test coverage: ten added JSON tests cover empty schemas/projections, roots/paths/arrays, malformed modes, empty input, batch/EOF progression, and partition materialization. Eight writer-backed WAL combinations cover empty/partial/reordered projections with and without schema discovery across multiple blocks and repeated EOF. The Hive suite compares file-field reads with partition-only counts/projections/grouping under both external COUNT settings, including file predicates and an absent partition. Existing tests cover populated projections, filtering, rejection, and split boundaries.
- Expected results: no generated result files change. WAL assertions check cardinality and projected values; Hive comparisons use the same fixture files as a differential oracle and do not depend on output ordering. The author-reported passing tests were not independently reproduced.
- Observability: existing parse/materialize/filter/I/O timing paths remain intact; scan-row accounting now includes accepted zero-column rows. No new logging or metric family is needed for the scalar cardinality bookkeeping.
- Transactions and persistence: WAL reads change, but write/replay serialization, transaction state, EditLog behavior, and failover protocols do not. Visible-version and delete-bitmap rules are unaffected; the existing delete/predicate filtering path remains in place.
- Data writes and atomicity: no new production data-write path or commit boundary is introduced.
- FE/BE variables: no new transmitted variables or send paths are added.
- Performance and memory: the added normal-path bookkeeping is scalar; JSON-path existence checks run only for empty projections. No new payload copies, large allocations, retained ownership, or pruning loss were identified. No benchmark was run.
- Other concerns: no further actionable issue remained after the complete and risk-focused reviews and final rechecks.
Validation limits: this was a static review; no builds, tests, benchmarks, or external Hive queries were executed. The WAL empty-projection guarantee is covered at the reader interface; production replay reaching an empty projection remains unverified, consistent with the PR description. These limits do not leave an unresolved defect candidate in the reviewed code.
Review converged after 1 round(s).
### What problem does this PR solve? Issue Number: close apache#69926 Related PR: apache#70154 Problem Summary: Add SQL-level integration coverage for the WAL reader row-count fix. Force two original async group-commit transactions to abort, then verify counts, NULLs, aggregates, filtering and field values after WAL replay. Keep the reader-level empty-projection regression cases as the precise defect reproduction. ### Release note None ### Check List (For Author) - Test: Run the new suite twice on isolated Doris 4.1.5 with scanner V2 enabled, using run-regression-test.sh to generate the output file and then compare results. Execution on master remains pending CI. - Behavior changed: No; regression coverage only. - Does this need documentation: No.
|
run buildall |
|
/review |
|
Codex automated review failed and did not complete. Error: Selected model is at capacity. Please try a different model. Please inspect the workflow logs and rerun the review after the underlying issue is resolved. |
TPC-H: Total hot run time: 28845 ms |
TPC-DS: Total hot run time: 151335 ms |
Local pipeline review — ✅ PASSschema: doris-repo-review/v1
status: PASS
pr: apache/doris#70154
commit: 8009387671d3ebcf51afedca65a6c252715e4f6d
base: 30ce25dc1f9579130cba38f5a9baed7c96187e12
reviewed_at: 2026-11-04T13:22+08:00
reviewer: Gabriel39
model: gpt-6-astra
effort: xhigh
findings: {blocker: 0, major: 0, minor: 0, nit: 0}
rounds: 1
converged: trueNotes for maintainers
Reviewed locally with the |
ClickBench: Total hot run time: 24.37 s |
) ### What problem does this PR solve? Issue Number: close #69926 Problem Summary: Hive JSON queries that only need partition columns can return zero rows even when the selected files contain records. For example, `SELECT * ... WHERE dt = 'p1'` returns data while `SELECT COUNT(*) ... WHERE dt = 'p1'` returns zero. The V2 JSON reader derived its row count from the output block, which has no columns after physical field pruning. Writer-backed reader tests reproduce the same row-count loss for empty WAL projections. Track accepted JSON records independently of materialized columns, including batch progress, array expansion, error rollback, and ignore-malformed NULL rows. Preserve JSON-path record selection for empty projections, and let the existing TableReader materialize partition values using the returned row count. For WAL, save the deserialized source row count before materialization transfers column ownership, then pass it through the existing filter pipeline. This preserves the row count when no file columns are requested. The empty-projection reproduction is at the reader interface; production replay reachability of an empty projection remains unverified. Add ten JSON BE tests covering empty file schemas and projections, arrays, JSON roots/paths, malformed input, batch boundaries, EOF, and actual TableReader partition materialization. Add eight writer-backed WAL cases covering empty, single-column, and reordered full projections across multiple blocks, with and without schema discovery, plus repeated EOF reads. Add a WAL SQL regression that forces two original async-load transactions to abort, then verifies row counts, NULLs, aggregates, filters, and actual values after replay. Add a Hive SQL regression using the existing partitioned JSON fixture for COUNT, partition projections, grouping, and file-column filters with external COUNT pushdown enabled and disabled. ### Release note Fix incorrect zero counts and missing rows when querying only partition columns of Hive JSON tables. Preserve logical row counts for empty WAL reader projections. ### Check List (For Author) - Test - [x] Unit Test: 166 ASAN tests passed, including JSON reader, TableReader, WAL V2 reader, WAL reader/writer, and CSV/Text empty-projection controls. Before the JSON fix, nine of ten new tests failed; before the WAL fix, both empty-projection cases failed while six projection controls passed. - [x] WAL SQL regression: `test_group_commit_wal_row_count` passed twice on isolated Doris 4.1.5 with scanner V2 enabled. Generated the `.out` file with `run-regression-test.sh`, then reran for result comparison. Execution on master is pending CI. - [x] Hive SQL regression: added `test_hive_json_partition_only`; Groovy compilation passed. Full execution against the external Hive fixture is pending CI. - Behavior changed: - [x] Yes. Empty JSON and WAL file projections preserve logical row counts. Hive JSON partition-only queries produce the correct rows and aggregates. - Does this need documentation? - [x] No.
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
…/JSON/WAL fixes (#70185) ### What problem does this PR solve? Backport the following master PRs to `branch-4.2`, in master merge order: 1. #69672 — Preserve source values and alias semantics in ES scans. 2. #69971 — Add session controls for Parquet page indexes and data-page size. 3. #70155 — Repair ES source predicate regression cases. 4. #70079 — Fix ORC condition-cache seeks past filtered stripe suffixes. 5. #70154 — Preserve JSON and WAL rows with empty file projections. The ES changes are adapted to the existing 4.2 FE planner and BE source locations. Mapping safety, scan-wide read mode, local residuals, native `esquery` handling and alias routing retain the upstream behavior without introducing the master connector framework. Added adapter tests cover both scan protocols, aliases, missing-value negations and native residual rejection. Preserve existing branch-specific ES regression coverage. Bring in the previously absent predicate suite, adapting its plan assertions to 4.2's `LOCAL_PREDICATES` output and retaining LIMIT result checks. Parquet variables use the 4.2 annotation interface and the original optional Thrift field IDs. The ORC dependency is pinned to the same fixed commit as #70079. The ES implementation also preserves source numeric and JSONB predicate semantics after scan-wide fallback. Numeric-token rounding must not make a remote predicate discard a row matching the value Doris materializes; empty JSONB objects remain nonnull even when ES indexes no leaf. Docvalue eligibility and pushdown are retained. Mapped date formats and their order are carried per concrete backing index through the existing property map to both scan protocols. Calendar/epoch alternatives now distinguish basic_date from epoch_millis, for strings and source numeric tokens. Numeric docvalues and older FE numeric requests retain their epoch decoder. Typed alias selection consistently uses the requested mapping type in schema inference and planning. The pinned ORC decoder's libdeflate dependency is included on ARM, matching master. ### Release note Fix ES source-value filtering, mapped dates and typed alias query correctness, ORC condition-cache seek crashes/missing rows and its ARM link dependency, and JSON/WAL row counts for empty file projections. Add Parquet output page-index and data-page-size session controls. ### Validation - FE compilation and Checkstyle passed. ES validation: 81 tests (48 datasource/planner tests and 33 legacy ES tests), 0 failures/errors, 1 external-environment skip. The 9 Parquet session-variable tests passed. - Rebuilt the pinned ORC dependency under AddressSanitizer: 56 focused tests passed, including 32 filtered-stripe-suffix seek cases. - Compiled all 10 affected Doris C++ implementation/test translation units and the ORC fixture generator. The regenerated fixture is byte-for-byte identical to the committed fixture. - clang-format 16 checks passed for all affected Doris C++ sources and headers. Modified Groovy suites compiled successfully. - The ES reader/parser implementations and test translation units compiled. The shared DATETIMEV2 date-format algorithm passed 21 standalone ASAN checks. CMake dependency checks passed for aarch64, arm64 and x86_64; an actual ARM link was not run locally. - Added `test_es_source_review_cases.groovy` with SQL-to-SQL checks against an internal reference table for numeric/JSONB source predicates, LIMIT, epoch-only formats, and explicit legacy DATETIMEV2 basic_date columns. It covers both scanners and parallel-scroll settings, waits for legacy metadata readiness, and restores session settings. The suite compiled; no golden files were handwritten. - The applicable ES fixes are synchronized to master in #70205. Master already links libdeflate on every architecture. - Full Doris BE unit-test execution and live external SQL regression were not performed locally; CI validation is requested. ### Check List (For Author) - Test - [x] Unit Test - [x] Regression tests included - Behavior changed: - [x] Yes; the upstream behavior is backported to 4.2. - Does this need documentation? - [x] Parquet controls are documented by the upstream documentation PR: apache/doris-website#4581 ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label
…ections #70154 (#70180) Cherry-picked from #70154 Co-authored-by: Gabriel <[email protected]>
) ### What problem does this PR solve? Backport three master fixes to `branch-4.1`: avoid unnecessary database-object loading for SCHEMATA scans, prevent ORC condition-cache seek crashes or missing rows, and preserve JSON/WAL row counts when no file columns are projected. The commits retain their original authors and are applied in master merge order: 1. #70010 — Avoid database-object enumeration when SCHEMATA only needs names. 2. #70079 — Advance safely past SARG-filtered ORC stripe suffixes during condition-cache seeks. 3. #70154 — Track logical JSON records independently of projected columns and capture WAL row counts before column ownership is transferred. Branch adaptations: - Keep Thrift field 7 reserved and add the optional `include_db_ids` flag at upstream field 8 with its default `true`. Preserve existing privilege checks, pattern matching and schema-name formatting for both enumeration paths. - Use the upstream fixed ORC dependency revision `5962bb071d6345cc29c5353d64d85a203525e4d9`, which descends from the branch's existing revision. - Resolve the JSON reader conflicts by retaining 4.1's error handling and adding logical row accounting without importing unrelated missing-field/load-rejection changes. Remove the rooted-array pre-count that consumes the ondemand cursor before JSON-path materialization; retain the upstream rooted-array coverage. ### Validation - The branch's FE production and test sources compiled with the existing Java 8 target settings. All **7 targeted FE tests passed**, including the existing `FrontendServiceImplTest#testGetDBNames`, the 100,000-namespace case, filtering and legacy-request compatibility. FE Checkstyle passed. - A fresh ASAN build of the exact pinned ORC dependency passed **56 focused tests**, including **32 filtered-stripe-suffix boundary cases**. - All **7 affected C++ implementation/test/generator translation units compiled**. Clang-format 16 passed for all **8 affected C++ source/header files**. - The ORC fixture generator reproduced the committed fixture byte for byte. All **3 added Groovy suites compiled**. - Full Doris BE unit-test execution and external SQL regression execution remain for CI; they were not run locally for this backport. ### Release note Improve SCHEMATA enumeration for large catalogs. Fix potential crashes or missing rows during ORC condition-cache seeks and incorrect JSON/WAL row counts with empty file projections. ### Check List (For Author) - Test - [x] Unit tests and focused dependency tests - [x] Regression tests included and compiled; full SQL execution pending CI - Behavior changed: - [x] Yes. Apply the upstream fixes while preserving branch-specific validation and protocol compatibility. - Does this need documentation? - [x] No. ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Add branch pick label ### ARM64 link dependency follow-up The ORC revision enables libdeflate ZLIB decoding on every architecture. Remove the old x86-only guard around `add_thirdparty(deflate)` so ARM64 BE links also receive the required library, matching master. An adjacent comment records this dependency invariant. Validation: probes include each branch's actual `be/cmake/thirdparty.cmake` and select `aarch64`, `arm64`, `x86` and `x86_64` dependency configurations. Before the fix, both ARM configurations fail to link with missing libdeflate symbols while both x86 controls pass. After the fix, all eight repository/configuration combinations link and pass a DEFLATE compression/decompression round trip. These probes run natively on x86_64 and validate CMake dependency selection; a native ARM64/full BE build remains for CI. Clang-format 16 passed for the PR-affected C++ files.
What problem does this PR solve?
Issue Number: close #69926
Problem Summary:
Hive JSON queries that only need partition columns can return zero rows even when the selected files contain records. For example,
SELECT * ... WHERE dt = 'p1'returns data whileSELECT COUNT(*) ... WHERE dt = 'p1'returns zero. The V2 JSON reader derived its row count from the output block, which has no columns after physical field pruning. Writer-backed reader tests reproduce the same row-count loss for empty WAL projections.Track accepted JSON records independently of materialized columns, including batch progress, array expansion, error rollback, and ignore-malformed NULL rows. Preserve JSON-path record selection for empty projections, and let the existing TableReader materialize partition values using the returned row count.
For WAL, save the deserialized source row count before materialization transfers column ownership, then pass it through the existing filter pipeline. This preserves the row count when no file columns are requested. The empty-projection reproduction is at the reader interface; production replay reachability of an empty projection remains unverified.
Add ten JSON BE tests covering empty file schemas and projections, arrays, JSON roots/paths, malformed input, batch boundaries, EOF, and actual TableReader partition materialization. Add eight writer-backed WAL cases covering empty, single-column, and reordered full projections across multiple blocks, with and without schema discovery, plus repeated EOF reads. Add a WAL SQL regression that forces two original async-load transactions to abort, then verifies row counts, NULLs, aggregates, filters, and actual values after replay. Add a Hive SQL regression using the existing partitioned JSON fixture for COUNT, partition projections, grouping, and file-column filters with external COUNT pushdown enabled and disabled.
Release note
Fix incorrect zero counts and missing rows when querying only partition columns of Hive JSON tables. Preserve logical row counts for empty WAL reader projections.
Check List (For Author)
test_group_commit_wal_row_countpassed twice on isolated Doris 4.1.5 with scanner V2 enabled. Generated the.outfile withrun-regression-test.sh, then reran for result comparison. Execution on master is pending CI.test_hive_json_partition_only; Groovy compilation passed. Full execution against the external Hive fixture is pending CI.