Jackie-Jiang opened a new pull request, #19164: URL: https://github.com/apache/pinot/pull/19164
## Summary > Stacked on [#19163](https://github.com/apache/pinot/pull/19163) — the first commit here belongs to that PR and will drop out of this diff once it merges. `MutableNoDictColumnStatistics.isSorted()` always walks the entire forward index for a single-valued raw column, reading and comparing every document. For `STRING` and `BYTES` that materializes a value per document just to find them all equal. A column holding a single distinct value is sorted regardless of the scan. The dictionary-encoded sibling gets this for free from `getCardinality() == 1`, but that is unavailable here — `getCardinality()` returns `UNKNOWN_CARDINALITY` for raw columns. The equivalent signal is the min/max pair, which is tracked per raw value during ingestion in `MutableSegmentImpl`, so `minValue.equals(maxValue)` identifies a constant column with no scan at all. Two properties worth stating explicitly: - **It never yields a false positive.** `equals` is at least as strict as `compareTo` for every stored type Pinot puts here, so equal bounds imply every value compares equal to both — including `Float`/`Double` `NaN`, where `equals` is true and `compareTo` is 0. Where the two disagree the error is in the safe direction: `BigDecimal.equals` also requires matching scale, so `1.0` vs `1.00` simply falls through to the scan. - **It is sufficient, not necessary.** Min and max are deliberately left null when aggregated metrics are enabled for a metric field, since the value changes over time. The null guard falls back to the scan in that case. `CompactedNoDictColumnStatistics` is unaffected — it overrides `isSorted()` with a value computed in its own single pass, and that pass already reads every value for min/max, element length, and ascii, so there is nothing to save there. ## Test coverage - `testConstantValueSkipsScan` — stubs equal min/max and asserts `verify(forwardIndex, never()).getInt(anyInt())`, so the assertion is on the interaction rather than the return value, which would be `true` either way - `testUntrackedMinMaxFallsBackToScan` — leaves min/max unstubbed (null) and asserts the scan still runs, pinning the aggregated-metrics fallback -- 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]
