branch-4.0: [fix](iceberg) Fix NPE in COUNT(*) pushdown when snapshot summary omits total-* counters (#64648)#65060
Merged
Conversation
… summary omits total-* counters (apache#64648) Backport of apache#64648 to branch-4.0. IcebergScanNode.getCountFromSnapshot() read total-equality-deletes / total-position-deletes / total-records from the snapshot summary and called .equals() / Long.parseLong() directly on the Map.get() results. An Iceberg snapshot summary is not guaranteed to carry these counters (snapshots written by compaction/replace, or some writers, may omit them), so `SELECT COUNT(*)` threw a NullPointerException on such tables while `SELECT *` worked fine. Extract the summary parsing into a pure static IcebergUtils.getCountFromSummary() that null-checks the counters and falls back to a normal scan (returns -1) when any is absent, and reuse it from both IcebergScanNode and IcebergUtils row-count estimation. On the BE side, IcebergTableReader::init_row_filters() now accepts a table-level row count of 0 (>= 0 instead of > 0) so a genuine pushed-down count of 0 takes the CountReader fast path. The BE change is applied to branch-4.0's be/src/vec/exec/format/table/iceberg_reader.cpp, since master's iceberg_reader_mixin.h does not exist on this branch. Co-Authored-By: Raghvendra Singh <raghav@cashify.in> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
Author
|
run buildall |
Contributor
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
hello-stephen
approved these changes
Jul 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Backport of #64648 to branch-4.0.
IcebergScanNode.getCountFromSnapshot()readtotal-equality-deletes/total-position-deletes/total-recordsfrom the Iceberg snapshot summary andcalled
.equals()/Long.parseLong()directly on theMap.get()results. AnIceberg snapshot summary is not guaranteed to carry these
total-*counters(snapshots written by compaction/replace, or some writers, may omit them), so
SELECT COUNT(*)threw aNullPointerExceptionon such tables whileSELECT *worked fine.
Fix
IcebergUtils.getCountFromSummary(summary, ignoreDanglingDelete)thatnull-checks the counters and falls back to a normal scan (
return -1) when anyrequired counter is absent, and reuse it from both
IcebergScanNodeandIcebergUtils.getIcebergRowCount().IcebergTableReader::init_row_filters()accepts a table-level row count of0(>= 0instead of> 0) so a genuine pushed-down count of 0 takes theCountReader fast path. Applied to this branch's
be/src/vec/exec/format/table/iceberg_reader.cpp(master'siceberg_reader_mixin.hdoes not exist on this branch).Unit test
IcebergCountPushDownTestcovers the missing-counter, no-delete,equality-delete, position-delete and zero-count cases.