Skip to content

fix(promql): set-op default matching is ignoring([]), not on([]) (#68) - #74

Merged
zzylol merged 1 commit into
mainfrom
fix/setop-default-match
Jul 2, 2026
Merged

fix(promql): set-op default matching is ignoring([]), not on([]) (#68)#74
zzylol merged 1 commit into
mainfrom
fix/setop-default-match

Conversation

@zzylol

@zzylol zzylol commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Closes #68 (MEDIUM, from the whole-repo review).

Bug

The parser attaches a default modifier to every and/or/unless (its matching is None). walk_binary mapped that to VectorMatch{On, []}byte-identical to an explicit on(). So a and b and a and on() b lowered to the same L3 tree, and the default "match on all shared labels" was misrepresented as "match on the empty label set".

Fix

The default is exactly ignoring([]) (ignore no labels ⇒ match on all shared labels). Map the None arm to Ignoring([]):

query before after
a and b (default) On([]) Ignoring([])
a and on() b On([]) On([])
a and ignoring() b Ignoring([]) Ignoring([])

Now default is distinct from explicit on() and correctly equal to explicit ignoring().

Verified

set_op_default_match_is_ignoring_empty_not_on_empty asserts both (assert_distinct("a and b", "a and on() b") + assert_equiv(["a and b", "a and ignoring() b"])). Existing binary-op e2e tests (arithmetic/comparison/on(job)) unaffected. Full suite green (29 binaries), clippy clean.

🤖 Generated with Claude Code

…n([]) (#68)

The parser attaches a default modifier to every `and`/`or`/`unless`, whose
`matching` is `None`. `walk_binary` mapped that to `VectorMatch{On, []}` —
byte-identical to an explicit `on()`. So `a and b` and `a and on() b` lowered
to the same tree, and the default "match on all shared labels" was
misrepresented as "match on the empty label set".

The default is exactly `ignoring([])` (ignore no labels ⇒ match on all shared
labels). Map the `None` arm to `Ignoring([])` instead:
  - `a and b`            → Ignoring([])
  - `a and on() b`       → On([])        (now distinct)
  - `a and ignoring() b` → Ignoring([])  (now correctly equal to default)

Added `set_op_default_match_is_ignoring_empty_not_on_empty` (distinct-vs-on,
equal-to-ignoring). Full workspace suite green; clippy --all-targets clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@zzylol
zzylol merged commit 29e6dc6 into main Jul 2, 2026
1 check passed
@zzylol
zzylol deleted the fix/setop-default-match branch July 2, 2026 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PromQL: set-op (and/or/unless) default matching collapses to explicit on()

1 participant