API: Implement startsWith bounds check in StrictMetricsEvaluator#15902
Open
bharos wants to merge 1 commit intoapache:mainfrom
Open
API: Implement startsWith bounds check in StrictMetricsEvaluator#15902bharos wants to merge 1 commit intoapache:mainfrom
bharos wants to merge 1 commit intoapache:mainfrom
Conversation
StrictMetricsEvaluator.startsWith() previously returned ROWS_MIGHT_NOT_MATCH unconditionally, without using column bounds. This misses the opportunity to determine that all rows in a file must match when both lower and upper bounds start with the given prefix. When both bounds start with the prefix, all values between them must also start with it, so the evaluator can return ROWS_MUST_MATCH. This enables whole-file matching optimizations for prefix-based operations.
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
Implements bounds-based evaluation for
startsWithinStrictMetricsEvaluator, replacing the unconditionalROWS_MIGHT_NOT_MATCHreturn with actual logic.Previously,
startsWithalways returnedROWS_MIGHT_NOT_MATCH,which prevented the engine from eliminating the residual predicate even
when file-level column bounds made it provable that every value started
with the given prefix.
Changes
StrictMetricsEvaluator.startsWith: Added checks for nestedcolumns, null-containing columns, and lower/upper bound comparisons
against the prefix. Returns
ROWS_MUST_MATCHwhen both bounds startwith the prefix.
TestStrictMetricsEvaluator: Added 9 test methods covering:both bounds match prefix, single-char prefix match, only lower bound
matches, bounds outside prefix range, wider range, missing stats,
all-nulls, some-nulls, and prefix longer than bounds.
How it works
For
STARTS WITH <prefix>:ROWS_MIGHT_NOT_MATCH(conservative)ROWS_MIGHT_NOT_MATCHthe upper bound (truncated to prefix length) equals the prefix →
ROWS_MUST_MATCH(all values in the file start with the prefix)ROWS_MIGHT_NOT_MATCH(conservative)This follows the same pattern used by
eqand the PR fornotStartsWithbounds (#15883) check in this class.Closes #15901