Skip to content

BE-482: HashQL: Remove logical not from MIR and fix postgres boolean lowering#8595

Open
indietyp wants to merge 17 commits into
mainfrom
bm/be-482-hashql-remove-logical-not-from-unary-operators
Open

BE-482: HashQL: Remove logical not from MIR and fix postgres boolean lowering#8595
indietyp wants to merge 17 commits into
mainfrom
bm/be-482-hashql-remove-logical-not-from-unary-operators

Conversation

@indietyp
Copy link
Copy Markdown
Member

🌟 What is the purpose of this PR?

Add proper boolean vs integer operator dispatch in the PostgreSQL SQL lowering, with ICE diagnostics for ambiguous cases and snapshot test coverage for all operator paths, as well as remove dedicated UnOp for logical not, in favour of bitwise not (similar to logical and and or being replaced).

🔍 What does this change?

  • Boolean/integer SQL operator dispatch: PostgreSQL requires different SQL operators for boolean and integer operands (NOT vs ~, AND vs &, OR vs |). The lowering now inspects the operand type via integer_type() and emits the correct SQL form.
  • ICE diagnostic for ambiguous operand types: Replaced three todo!() panics in the filter compiler with a proper AmbiguousIntegerType diagnostic (Severity::Bug). This fires if the operand type cannot be classified as boolean or integer, which is currently unreachable but would surface issues if GVN ever produces union-typed operands.
  • UnOp documentation: Added enum-level and per-variant doc comments matching the existing BinOp style.
  • op! macro fix: Unary operator arms now produce hashql_mir::body::rvalue::UnOp directly instead of hashql_hir::node::operation::UnOp, fixing a type mismatch in the builder.
  • SQL pretty-printing: Improved formatting of transpiled SQL in snapshot output.
  • New snapshot tests:
    • binary_bitand_boolean_and: & on booleans lowers to AND
    • binary_bitor_boolean_or: | on booleans lowers to OR
    • binary_bitor_bigint_cast: | on integers lowers to |

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • does not modify any publishable blocks or libraries, or modifications do not need publishing

📜 Does this require a change to the docs?

The changes in this PR:

  • are internal and do not require a docs change

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

⚠️ Known issues

A future improvement would be to trace the type via the compiled SQL expression side rather than through the MIR operand type. This would allow disambiguation in cases where integer_type() cannot resolve (e.g. union types from GVN), since the SQL expression tree could carry its own type information. This is currently not needed as there's no way a union like that could be created.

🐾 Next steps

  • Consider expression-side type tracing as an alternative to integer_type() for operator dispatch, which would handle ambiguous union types gracefully instead of emitting an ICE.

🛡 What tests cover this?

  • New snapshot tests: binary_bitand_boolean_and, binary_bitor_boolean_or, binary_bitor_bigint_cast
  • Existing snapshot tests: unary_not (boolean NOT), unary_bitnot (integer NOT), binary_bitand_bigint_cast (integer AND)

❓ How to test this?

  1. cargo test --package hashql-eval -- postgres::filter::tests
  2. Confirm all snapshot tests pass, including the three new boolean/integer operator dispatch tests.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview, Comment May 26, 2026 7:36am
hashdotdesign Ready Ready Preview, Comment May 26, 2026 7:36am
petrinaut Ready Ready Preview May 26, 2026 7:36am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hashdotdesign-tokens Ignored Ignored Preview May 26, 2026 7:36am

Copy link
Copy Markdown
Member Author

indietyp commented Mar 28, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 28, 2026

Codecov Report

❌ Patch coverage is 85.07109% with 63 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.10%. Comparing base (cb459a8) to head (a0ace5a).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ass/execution/statement_placement/embedding/mod.rs 53.12% 15 Missing ⚠️
libs/@local/hashql/eval/src/postgres/filter/mod.rs 83.56% 12 Missing ⚠️
libs/@local/hashql/mir/src/body/rvalue/unary.rs 33.33% 10 Missing ⚠️
libs/@local/hashql/eval/src/postgres/types.rs 55.00% 9 Missing ⚠️
libs/@local/hashql/mir/src/pretty/text.rs 75.00% 7 Missing ⚠️
...hashql/mir/src/pass/transform/inst_simplify/mod.rs 20.00% 4 Missing ⚠️
...cal/hashql/mir/src/pass/execution/splitting/mod.rs 97.01% 1 Missing and 1 partial ⚠️
...pass/execution/statement_placement/postgres/mod.rs 93.75% 1 Missing and 1 partial ⚠️
libs/@local/hashql/eval/src/postgres/error.rs 0.00% 1 Missing ⚠️
libs/@local/hashql/mir/src/reify/rvalue.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8595      +/-   ##
==========================================
+ Coverage   58.81%   59.10%   +0.28%     
==========================================
  Files        1328     1340      +12     
  Lines      126811   129156    +2345     
  Branches     5790     5837      +47     
==========================================
+ Hits        74580    76332    +1752     
- Misses      51350    51923     +573     
- Partials      881      901      +20     
Flag Coverage Δ
apps.hash-api 0.00% <ø> (ø)
local.claude-hooks 0.00% <ø> (ø)
local.harpc-client 51.24% <ø> (ø)
rust.error-stack 90.87% <ø> (ø)
rust.harpc-net 96.19% <ø> (-0.04%) ⬇️
rust.harpc-tower 67.03% <ø> (ø)
rust.harpc-types 0.00% <ø> (ø)
rust.hash-codec 72.76% <ø> (ø)
rust.hash-graph-store 37.76% <ø> (ø)
rust.hash-graph-types 0.00% <ø> (ø)
rust.hash-graph-validation 83.45% <ø> (ø)
rust.hashql-ast 87.23% <ø> (ø)
rust.hashql-eval 75.69% <76.59%> (-1.85%) ⬇️
rust.hashql-mir 86.74% <87.50%> (-0.02%) ⬇️
rust.hashql-syntax-jexpr 94.06% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

Comment thread libs/@local/hashql/eval/src/postgres/filter/mod.rs Fixed
Comment thread libs/@local/hashql/eval/src/postgres/filter/mod.rs Fixed
Comment thread libs/@local/hashql/eval/src/postgres/filter/tests.rs Fixed
Comment thread libs/@local/hashql/eval/src/postgres/filter/tests.rs Fixed
Comment thread libs/@local/hashql/eval/src/postgres/filter/tests.rs Fixed
Comment thread libs/@local/hashql/eval/src/postgres/filter/tests.rs Fixed
Comment thread libs/@local/hashql/eval/src/postgres/filter/tests.rs Fixed
Comment thread libs/@local/hashql/eval/src/postgres/types.rs Fixed
Comment thread libs/@local/hashql/eval/src/postgres/types.rs Fixed
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 28, 2026

Merging this PR will not alter performance

✅ 80 untouched benchmarks


Comparing bm/be-482-hashql-remove-logical-not-from-unary-operators (a0ace5a) with bm/be-474-hashql-take-into-account-terminators-eligibility-when (65a8a94)

Open in CodSpeed

@github-actions
Copy link
Copy Markdown
Contributor

Benchmark results

@rust/hash-graph-benches – Integrations

policy_resolution_large

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2002 $$27.2 \mathrm{ms} \pm 191 \mathrm{μs}\left({\color{gray}-1.963 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.35 \mathrm{ms} \pm 18.2 \mathrm{μs}\left({\color{gray}0.198 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1001 $$12.1 \mathrm{ms} \pm 92.6 \mathrm{μs}\left({\color{gray}-0.114 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 3314 $$42.4 \mathrm{ms} \pm 374 \mathrm{μs}\left({\color{gray}-2.866 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$13.8 \mathrm{ms} \pm 107 \mathrm{μs}\left({\color{gray}1.25 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 1526 $$23.7 \mathrm{ms} \pm 179 \mathrm{μs}\left({\color{gray}-4.869 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 2078 $$28.1 \mathrm{ms} \pm 190 \mathrm{μs}\left({\color{gray}-1.349 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.63 \mathrm{ms} \pm 20.6 \mathrm{μs}\left({\color{gray}-1.803 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 1033 $$13.2 \mathrm{ms} \pm 125 \mathrm{μs}\left({\color{gray}-0.896 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_medium

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 102 $$3.83 \mathrm{ms} \pm 23.0 \mathrm{μs}\left({\color{gray}1.57 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.97 \mathrm{ms} \pm 18.4 \mathrm{μs}\left({\color{gray}2.34 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 51 $$3.40 \mathrm{ms} \pm 17.0 \mathrm{μs}\left({\color{gray}1.41 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 269 $$5.34 \mathrm{ms} \pm 33.9 \mathrm{μs}\left({\color{gray}4.82 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.53 \mathrm{ms} \pm 21.6 \mathrm{μs}\left({\color{gray}0.433 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 107 $$4.11 \mathrm{ms} \pm 23.4 \mathrm{μs}\left({\color{gray}-0.104 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 133 $$4.46 \mathrm{ms} \pm 21.7 \mathrm{μs}\left({\color{gray}1.64 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.40 \mathrm{ms} \pm 21.7 \mathrm{μs}\left({\color{gray}1.23 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 63 $$4.21 \mathrm{ms} \pm 28.9 \mathrm{μs}\left({\color{gray}4.63 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_none

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2 $$2.66 \mathrm{ms} \pm 14.6 \mathrm{μs}\left({\color{gray}-0.067 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.60 \mathrm{ms} \pm 13.2 \mathrm{μs}\left({\color{gray}-0.716 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1 $$2.71 \mathrm{ms} \pm 16.3 \mathrm{μs}\left({\color{gray}-0.576 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 8 $$2.99 \mathrm{ms} \pm 17.5 \mathrm{μs}\left({\color{gray}-0.036 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.79 \mathrm{ms} \pm 16.6 \mathrm{μs}\left({\color{gray}0.659 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 3 $$3.07 \mathrm{ms} \pm 21.4 \mathrm{μs}\left({\color{gray}-0.242 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_small

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 52 $$3.05 \mathrm{ms} \pm 16.7 \mathrm{μs}\left({\color{gray}-0.982 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.77 \mathrm{ms} \pm 18.9 \mathrm{μs}\left({\color{gray}1.29 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 25 $$2.91 \mathrm{ms} \pm 16.7 \mathrm{μs}\left({\color{gray}-2.813 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 94 $$3.50 \mathrm{ms} \pm 16.7 \mathrm{μs}\left({\color{gray}1.50 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.16 \mathrm{ms} \pm 18.8 \mathrm{μs}\left({\color{gray}-1.333 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 26 $$3.30 \mathrm{ms} \pm 21.5 \mathrm{μs}\left({\color{gray}-4.868 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 66 $$3.39 \mathrm{ms} \pm 20.6 \mathrm{μs}\left({\color{gray}0.029 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.98 \mathrm{ms} \pm 16.6 \mathrm{μs}\left({\color{gray}-3.689 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 29 $$3.31 \mathrm{ms} \pm 33.1 \mathrm{μs}\left({\color{gray}-0.274 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_complete

Function Value Mean Flame graphs
entity_by_id;one_depth 1 entities $$43.9 \mathrm{ms} \pm 200 \mathrm{μs}\left({\color{gray}0.777 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 10 entities $$80.3 \mathrm{ms} \pm 427 \mathrm{μs}\left({\color{gray}-1.030 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 25 entities $$49.1 \mathrm{ms} \pm 206 \mathrm{μs}\left({\color{gray}-0.070 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 5 entities $$52.1 \mathrm{ms} \pm 356 \mathrm{μs}\left({\color{gray}2.09 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 50 entities $$59.1 \mathrm{ms} \pm 314 \mathrm{μs}\left({\color{gray}-1.595 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 1 entities $$45.5 \mathrm{ms} \pm 204 \mathrm{μs}\left({\color{gray}-0.462 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 10 entities $$418 \mathrm{ms} \pm 1.20 \mathrm{ms}\left({\color{gray}-0.623 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 25 entities $$99.8 \mathrm{ms} \pm 433 \mathrm{μs}\left({\color{gray}-0.015 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 5 entities $$88.8 \mathrm{ms} \pm 353 \mathrm{μs}\left({\color{gray}-0.899 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 50 entities $$287 \mathrm{ms} \pm 809 \mathrm{μs}\left({\color{lightgreen}-8.347 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 1 entities $$18.8 \mathrm{ms} \pm 96.7 \mathrm{μs}\left({\color{gray}-1.811 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 10 entities $$19.6 \mathrm{ms} \pm 101 \mathrm{μs}\left({\color{gray}-1.015 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 25 entities $$19.6 \mathrm{ms} \pm 91.2 \mathrm{μs}\left({\color{gray}-1.372 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 5 entities $$19.6 \mathrm{ms} \pm 109 \mathrm{μs}\left({\color{gray}-0.395 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 50 entities $$24.0 \mathrm{ms} \pm 131 \mathrm{μs}\left({\color{gray}0.954 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$18.7 \mathrm{ms} \pm 97.5 \mathrm{μs}\left({\color{gray}-2.809 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$18.9 \mathrm{ms} \pm 126 \mathrm{μs}\left({\color{gray}0.412 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$19.0 \mathrm{ms} \pm 108 \mathrm{μs}\left({\color{gray}0.038 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$19.4 \mathrm{ms} \pm 112 \mathrm{μs}\left({\color{gray}0.366 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$26.0 \mathrm{ms} \pm 276 \mathrm{μs}\left({\color{gray}1.93 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity

Function Value Mean Flame graphs
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 $$32.1 \mathrm{ms} \pm 271 \mathrm{μs}\left({\color{gray}-2.138 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$35.3 \mathrm{ms} \pm 303 \mathrm{μs}\left({\color{gray}2.35 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$33.0 \mathrm{ms} \pm 290 \mathrm{μs}\left({\color{gray}-2.585 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$34.1 \mathrm{ms} \pm 285 \mathrm{μs}\left({\color{gray}-0.854 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$35.6 \mathrm{ms} \pm 328 \mathrm{μs}\left({\color{gray}4.91 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$34.8 \mathrm{ms} \pm 269 \mathrm{μs}\left({\color{gray}-0.361 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$34.5 \mathrm{ms} \pm 287 \mathrm{μs}\left({\color{gray}0.538 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$34.2 \mathrm{ms} \pm 336 \mathrm{μs}\left({\color{gray}3.05 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$34.5 \mathrm{ms} \pm 303 \mathrm{μs}\left({\color{gray}1.23 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity_type

Function Value Mean Flame graphs
get_entity_type_by_id Account ID: bf5a9ef5-dc3b-43cf-a291-6210c0321eba $$8.32 \mathrm{ms} \pm 42.5 \mathrm{μs}\left({\color{gray}0.182 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property traversal_paths=0 0 $$94.5 \mathrm{ms} \pm 528 \mathrm{μs}\left({\color{gray}0.835 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$142 \mathrm{ms} \pm 630 \mathrm{μs}\left({\color{gray}-0.984 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$101 \mathrm{ms} \pm 586 \mathrm{μs}\left({\color{gray}1.06 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$110 \mathrm{ms} \pm 606 \mathrm{μs}\left({\color{gray}-0.489 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$119 \mathrm{ms} \pm 676 \mathrm{μs}\left({\color{gray}-2.065 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$125 \mathrm{ms} \pm 766 \mathrm{μs}\left({\color{gray}1.19 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=0 0 $$98.6 \mathrm{ms} \pm 461 \mathrm{μs}\left({\color{gray}-1.071 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$127 \mathrm{ms} \pm 686 \mathrm{μs}\left({\color{gray}-1.068 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$105 \mathrm{ms} \pm 596 \mathrm{μs}\left({\color{gray}-1.403 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$114 \mathrm{ms} \pm 821 \mathrm{μs}\left({\color{gray}-1.792 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$116 \mathrm{ms} \pm 784 \mathrm{μs}\left({\color{gray}-0.679 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$117 \mathrm{ms} \pm 695 \mathrm{μs}\left({\color{gray}0.479 \mathrm{\%}}\right) $$

scenarios

Function Value Mean Flame graphs
full_test query-limited $$133 \mathrm{ms} \pm 639 \mathrm{μs}\left({\color{gray}3.22 \mathrm{\%}}\right) $$ Flame Graph
full_test query-unlimited $$144 \mathrm{ms} \pm 474 \mathrm{μs}\left({\color{gray}2.56 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-limited $$103 \mathrm{ms} \pm 417 \mathrm{μs}\left({\color{gray}-2.509 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-unlimited $$543 \mathrm{ms} \pm 2.42 \mathrm{ms}\left({\color{gray}-1.984 \mathrm{\%}}\right) $$ Flame Graph

@indietyp indietyp force-pushed the bm/be-474-hashql-take-into-account-terminators-eligibility-when branch from 1646ca9 to fb03f81 Compare April 29, 2026 15:32
@indietyp indietyp force-pushed the bm/be-482-hashql-remove-logical-not-from-unary-operators branch from a5f3a6a to 68d7a83 Compare April 29, 2026 15:32
@indietyp indietyp force-pushed the bm/be-482-hashql-remove-logical-not-from-unary-operators branch from 68d7a83 to 1685178 Compare April 29, 2026 15:40
@indietyp indietyp marked this pull request as ready for review April 29, 2026 15:42
@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 29, 2026

PR Summary

Medium Risk
Changes SQL generation for filters and graph reads; incorrect operator choice would affect query results, though behavior is heavily snapshot-tested.

Overview
This PR unifies logical and bitwise negation in MIR by dropping a separate UnOp::Not: HIR ! and ~ both lower to UnOp::BitNot, and tests/macros now use un.~ instead of un.!.

PostgreSQL filter lowering now picks SQL operators from operand types via integer_type(): booleans get NOT, AND, and OR (with ::boolean casts); integers get ~, &, and | (with ::bigint where needed). Unresolved operands emit an AmbiguousIntegerType bug diagnostic instead of panicking.

Snapshot coverage adds boolean &/| cases, runs sqruff on generated SQL for formatting, and refreshes many postgres filter snapshots. MIR interpreter, inst-simplify, and related UI snapshots are updated for the BitNot-only unary model.

Reviewed by Cursor Bugbot for commit a0ace5a. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread libs/@local/hashql/mir/src/interpret/tests.rs Outdated
Comment thread libs/@local/hashql/eval/src/postgres/filter/tests.rs
@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented Apr 29, 2026

🤖 Augment PR Summary

Summary: This PR simplifies HashQL MIR unary operators by removing a dedicated logical NOT, and fixes PostgreSQL SQL lowering to correctly choose boolean vs integer operator forms.

Changes:

  • Collapse HIR unary NOT/bitwise-NOT into a single MIR UnOp::BitNot (plus Neg), updating builders, reification, interpreter, and passes accordingly.
  • Add Postgres operator dispatch so ~/&/| lower to NOT/AND/OR for booleans, and to bitwise operators for integers.
  • Introduce integer_type() classification helper and a new AmbiguousIntegerType ICE diagnostic to replace previous todo!() panics.
  • Export VariadicOperator from the Postgres query module and use variadic expressions for boolean conjunction/disjunction lowering.
  • Improve snapshot readability by running generated SQL through sqruff in tests and updating existing snapshots; add new snapshot tests for boolean/integer operator paths.

Technical Notes: The Postgres lowering now relies on MIR operand typing (via integer_type()) to select SQL operators; ambiguous/unclassifiable types emit a bug-level diagnostic and lower to NULL.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9be4564. Configure here.

Comment thread libs/@local/hashql/eval/src/postgres/filter/mod.rs
Comment thread libs/@local/hashql/eval/src/postgres/filter/mod.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/deps Relates to third-party dependencies (area) area/libs Relates to first-party libraries/crates/packages (area) area/tests New or updated tests type/eng > backend Owned by the @backend team

Development

Successfully merging this pull request may close these issues.

2 participants