feiniaofeiafei opened a new pull request, #68435:
URL: https://github.com/apache/doris/pull/68435
### What problem does this PR solve?
Related PR: #67067
Problem Summary:
Greedy join reorder before eager aggregation can fail while planning valid
aggregate queries when derived statistics contain `NaN`. For example, after a
filter estimates zero rows, arithmetic expression statistics and null-safe
equality can propagate a non-finite row count into a join cluster.
Because comparisons with `NaN` are always false, the enumerator can leave
either the selected group or its best plan unset, causing a null pointer when
accessing `leftGroup.atoms` or `group.bestPlanInfo.plan`. An atom cost of
`Double.MAX_VALUE` can also fail to beat the initial cost sentinel.
This change rejects non-finite estimated row counts during atom
initialization and join enumeration, propagates failure through both linear and
bushy enumeration, and uses the existing fallback to retain the original join
plan. Finite atom costs are bounded consistently with join costs. It does not
change the underlying statistics estimation formulas.
The regression reduces the failing queries to small tables and checks
results with reordering both enabled and disabled, covering zero-row filters,
outer joins, empty tables, NULL-safe matches, and nonempty aggregates. Expected
output was generated with the standard regression runner using reordering
disabled. Unit tests cover non-finite atom/join/bushy costs, the maximum finite
atom cost, and retention of the original plan.
### Release note
Fix planning failures for aggregate joins with non-finite intermediate
statistics during eager join reorder.
### Check List (For Author)
- Test
- [x] Regression test
- [x] Unit Test
- [x] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- Behavior changed:
- [ ] No.
- [x] Yes. Affected queries retain the original join plan instead of
failing during planning.
- Does this need documentation?
- [x] No.
- [ ] Yes.
Validation:
- `DISABLE_BUILD_UI=ON ./build.sh --fe` passed, including Checkstyle. UI was
skipped because the validation host has Node 16; the FE libraries were deployed
to the test cluster.
- `./run-fe-ut.sh --run
org.apache.doris.nereids.rules.rewrite.joinorder.JoinReorderGreedyTest,org.apache.doris.nereids.rules.rewrite.joinorder.JoinReorderRuleTest`:
17 tests passed, with no failures, errors, or skips.
- `./run-regression-test.sh --conf <test-cluster-config> --run -d
query_p0/eager_agg -s
join_reorder_non_finite_stats,join_reorder_before_eager_agg`: both suites
passed. The new regression reproduced the null pointer before the fix.
- Replayed 12 original RQG queries. Temporary diagnostics confirmed `NaN` at
the cost computation entry in all 12; these diagnostics are removed from the
final change. With the fix, all queries succeeded and every result matched the
baseline obtained with reordering disabled.
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]