[fix](fe) refuse broadcast join when build-side row count was clamped from unknown#65900
Open
Baymine wants to merge 1 commit into
Open
[fix](fe) refuse broadcast join when build-side row count was clamped from unknown#65900Baymine wants to merge 1 commit into
Baymine wants to merge 1 commit into
Conversation
… from unknown ### What problem does this PR solve? Issue Number: close apache#65899 Problem Summary: When an Olap or external (Hive/Iceberg/etc.) table has not been ANALYZE'd, its row count is propagated as UNKNOWN_ROW_COUNT (-1) from BE/catalog. StatsCalculator then clamps this -1 up to 1 row so the cost model (which cannot tolerate negatives) keeps working. The resulting "1 row" looks tiny, so JoinUtils.checkBroadcastJoinStats happily picks that table as the broadcast build side — even though its true size is unknown and potentially huge. At runtime the un-ANALYZE'd large table gets fully materialized on every BE node, causing OOM. This adds a `rowCountWasUnknown` flag to Statistics (propagated through the copy ctor, the 6-arg ctor, StatisticsBuilder, and the withRowCount* family) that records whether the row count was clamped from UNKNOWN. StatsCalculator sets it in computeOlapScan and computeCatalogRelation (refreshing it in the external path so a row count recovered from per-column stats clears the flag). JoinUtils.checkBroadcastJoinStats now refuses broadcast when the flag is set, in addition to the existing guards. ### Release note When a table has not been analyzed, its row count is unknown and is internally clamped to 1. Previously such a table could be chosen as the broadcast join build side because 1 row looks small, leading to OOM at runtime on large un-analyzed tables. The optimizer now refuses broadcast for a build side whose row count was clamped from unknown, falling back to shuffle join instead. ### Check List (For Author) - Test - [ ] Regression test - [x] Unit Test - [ ] Manual test (add detailed scripts or steps below) - [ ] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [ ] Previous test can cover this change. - [ ] No code files have been changed. - [ ] Other reason <!-- Add your reason? --> - Behavior changed: - [x] Yes. An un-analyzed table whose row count was previously clamped to 1 will no longer be eligible as a broadcast join build side; the optimizer falls back to shuffle join. This avoids OOM but may change plans for queries that previously (possibly wrongly) used broadcast. - Does this need documentation? - [x] No. Internal optimizer stats-tracking change; no user-facing knob.
Baymine
requested review from
924060929,
englefly,
morrySnow and
starocean999
as code owners
July 22, 2026 09:03
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
Author
|
run buildall |
Contributor
TPC-H: Total hot run time: 29488 ms |
Contributor
TPC-DS: Total hot run time: 177962 ms |
Contributor
ClickBench: Total hot run time: 25.04 s |
Contributor
FE UT Coverage ReportIncrement line coverage |
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.
What problem does this PR solve?
Issue Number: close #65899
Problem Summary:
When an Olap or external (Hive/Iceberg/etc.) table has not been ANALYZE'd, its row count is propagated as UNKNOWN_ROW_COUNT (-1) from BE/catalog.
StatsCalculatorthen clamps this -1 up to 1 row so the cost model (which cannot tolerate negatives) keeps working. The resulting "1 row" looks tiny, soJoinUtils.checkBroadcastJoinStatshappily picks that table as the broadcast build side — even though its true size is unknown and potentially huge. At runtime the un-ANALYZE'd large table gets fully materialized on every BE node, causing OOM.This adds a
rowCountWasUnknownflag toStatistics(propagated through the copy ctor, the 6-arg ctor,StatisticsBuilder, and thewithRowCount*family) that records whether the row count was clamped from UNKNOWN.StatsCalculatorsets it incomputeOlapScanandcomputeCatalogRelation(refreshing it in the external path so a row count recovered from per-column stats clears the flag).JoinUtils.checkBroadcastJoinStatsnow refuses broadcast when the flag is set, in addition to the existing guards.Release note
When a table has not been analyzed, its row count is unknown and is internally clamped to 1. Previously such a table could be chosen as the broadcast join build side because 1 row looks small, leading to OOM at runtime on large un-analyzed tables. The optimizer now refuses broadcast for a build side whose row count was clamped from unknown, falling back to shuffle join instead.
Check List (For Author)