englefly opened a new pull request, #70911: URL: https://github.com/apache/doris/pull/70911
### Background Doris collects top-value frequencies among the non-NULL rows of a column. Nereids can use these frequencies to estimate equality and IN predicates on skewed columns. ### What problem does this PR solve? Issue Number: None Related PR: #54035 (introduced hot-value filter estimation) PR Type: Bugfix Problem Summary: Equality and IN predicates whose literals all miss the hot-value map estimate from the full NDV. In the regression fixture, 320 of 1,600 rows are NULL and one value accounts for 87.5% of the non-NULL rows. Each of the four other values is estimated at 256 rows on master and 40 rows after accounting for the remaining frequency. Two cold IN values go from 512 rows to 80. Two-decimal collection also loses precision for small frequencies. ### Details - **Frequency:** Always for supported literal equality and valid-range IN predicates that miss a recorded skew distribution. - **Root cause:** FilterEstimation used 1 / NDV for a missed equality, and IN tested whether its output contained hot values before using the input distribution. The collection templates rounded frequencies to two decimal places. - **Why existing tests missed it:** FilterEstimationTest covered hot equality and mixed IN lists. The test_full_analyze_hot_value regression checks readily representable frequencies such as 0.5. Neither asserted the estimate of a cold-only predicate or a sufficiently small collected frequency. - **Fix:** Share the remaining-frequency and NDV calculation, add frequencies for matching hot values, and apply the non-NULL fraction once. Count legacy zero-frequency entries in the remaining distribution. Collect frequencies to six decimal places using the same persisted representation. - **Other paths and branches:** The estimator is shared by logical and physical filters. The affected collection templates serve full and DUJ1 sample analysis. The filter pattern is present in branch-4.0, branch-4.1 and branch-4.2. branch-2.1, branch-3.0 and branch-3.1 lack the hot-aware filter paths. - **Behavior change:** Cold predicates on skewed columns receive estimates based on the remaining distribution, and newly collected hot frequencies have more precision. ### Testing - The cold_value_selectivity regression covers cold equality, cold-only and mixed IN lists, a hot equality, and a fresh full hot-value analysis. Local FE unit tests passed for FilterEstimationTest. - Full-collection cases before the DUJ1 stage in test_full_analyze_hot_value passed. The DUJ1 sample query hit the same unsupported plan node on the unmodified master FE and the patched FE with the local 4.1.5 BE. - Regenerated 1,204 shape snapshots and verified 1,205 shape_check suites with the regression runner. The regenerated snapshots match the checked-in files. - Built the FE with `build.sh --fe`. Local SQL regression used the Doris 4.1.5 BE with compatibility settings for data execution. ### Release note Nereids improves estimates for infrequent values on skewed columns and uses finer hot-value frequencies after statistics collection. ### Check List (For Author) - Behavior changed: Yes (see Details) - Does this need documentation: No - Pre-submission status: Partially verified: local DUJ1 integration requires a BE that supports the sample query plan. The same query fails with the same BE error on master. ### AI Disclosure - Tool: OpenAI Codex (GPT-6) - Generated: Code, tests, and PR description - Human review: Pending -- 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]
