Fix NOT BETWEEN compiling to the same filter as BETWEEN in metrics SQL#9719
Merged
Conversation
…-between-filter # Conflicts: # runtime/metricsview/metricssql/filter_parser_test.go
k-anshul
approved these changes
Jul 21, 2026
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.
parseBetweeninruntime/metricsview/metricssql/filter_parser.goignored the AST'sNotflag, sox NOT BETWEEN 1 AND 10compiled to the same expression asx BETWEEN 1 AND 10— the range filter was silently inverted.NOT BETWEENcompiles to(x < low OR x > high); plainBETWEENoutput is unchanged.TestParseFiltercases for both forms.Steps to reproduce:
metricssql.ParseFilter("x NOT BETWEEN 1 AND 10")(or use the filter in any metrics SQLWHEREclause).{op: and, [{gte, x, 1}, {lte, x, 10}]}— identical tox BETWEEN 1 AND 10, so every row the filter was meant to exclude was included and vice versa.{op: or, [{lt, x, 1}, {gt, x, 10}]}.Checklist: