Repository navigation
fix(plan): intersect BETWEEN selectivity with column domain - #32224
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 4c5942ab6ce38c85b9684a7a9472c4f0f2192ed5
Assessment: approve
Both estimators correctly reuse the existing interval estimator to clip BETWEEN ranges, preserving conversions and fallbacks without adding production mechanisms. Boundary tests and SQL regressions cover the defect; no actionable findings remain.
Model: gpt-6.1-sol / max
Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0
Validation:
-
Reviewed the complete delta, linked issues, discussion, interval helper, binding path and statistics consumers.
-
Reused frozen-head CI successes for Linux UT/coverage, arm64 static analysis and both BVT groups.
-
Local source-audit.py passed: clean frozen source, diff/gofmt checks, 24 boundary expectations and seven SQL selectivity/result pairs; receipt checks/1793857366677901778-2.json and source-audit.log.
Limitations:
- No local Go or service tests were rerun. Detailed author execution logs were not supplied; separate prefix-selectivity behavior remains outside this fix.
✅ Merged into
|
aunjgr
left a comment
There was a problem hiding this comment.
Reviewed the complete diff and the existing interval estimator/callers. Both numeric and decimal BETWEEN/in_range paths now intersect the column domain, with the existing unsupported-literal fallback and decimal endpoint scaling preserved. The boundary, binder and SQL regressions cover disjoint/overlap/full-coverage cases without changing query evaluation semantics.
No blocking findings. Reused the successful latest head CI (UT, SCA, coverage and both BVT topologies); superseded canceled runs were not treated as current failures. No local execution was performed.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #32046
What this PR does / why we need it:
The numeric and decimal min/max estimators score BETWEEN predicates by the query range's width, even when it does not intersect the column's observed domain.
Reuse the existing interval estimator in both paths to clip the range to the column domain, return near-zero selectivity for empty intersections, and correctly handle full coverage and singleton domains. Preserve decimal literal scaling and leave the separate fixed-selectivity behavior tracked in #31994 unchanged.
Add deterministic boundary/type tests, a parse/bind/build regression, and a four-row SQL regression checking scan selectivity and actual results for integer, Decimal64, and Decimal128 columns.
Validation (Go 1.27.1, macOS arm64):
pkg/sql/plantest package passed throughmo-cgo-test; both changed production statements are covered (100%).