Skip to content

feat(queryopt): absorption-idempotency optimizer#3051

Open
jzelinskie wants to merge 4 commits intoauthzed:mainfrom
jzelinskie:absorption-optim
Open

feat(queryopt): absorption-idempotency optimizer#3051
jzelinskie wants to merge 4 commits intoauthzed:mainfrom
jzelinskie:absorption-optim

Conversation

@jzelinskie
Copy link
Copy Markdown
Member

Description

This PR implements a new optimizer pass that canonicalizes the structure of union expressions according two to laws from set theory: idempotency (A ∪ A = A) and absorption (A ∪ (A ∩ B) = A).

Caveats are treated as opaque structural units: A ∪ Caveat(A) is not simplified, but A ∪ (A ∩ Caveat(B)) = A because A appears as a direct factor.

Arrows are treated as opaque structural units: (A->B) ∪ (A->B ∩ C) = A->B, but (A->B) ∪ (A->C) is not simplified.

This must run after caveat pushdown so it sees the final caveat shape and before reachability-pruning so pruning works on a smaller tree.

Testing

Added unit tests, but also ran the full test suite. LMK if I need to add any other kind of tests when adding optimizers

References

@github-actions github-actions bot added the area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) label Apr 15, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

❌ Patch coverage is 93.97590% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.69%. Comparing base (3263d73) to head (6e45bdc).

Files with missing lines Patch % Lines
pkg/query/queryopt/absorption.go 93.83% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3051      +/-   ##
==========================================
+ Coverage   73.64%   73.69%   +0.06%     
==========================================
  Files         499      500       +1     
  Lines       60165    60248      +83     
==========================================
+ Hits        44301    44393      +92     
+ Misses      12674    12666       -8     
+ Partials     3190     3189       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jzelinskie jzelinskie marked this pull request as ready for review April 15, 2026 22:52
@jzelinskie jzelinskie requested a review from a team as a code owner April 15, 2026 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant