Skip to content

feat: support quantified subqueries#339

Merged
KKould merged 2 commits intomainfrom
feat/quantified-subquery
May 4, 2026
Merged

feat: support quantified subqueries#339
KKould merged 2 commits intomainfrom
feat/quantified-subquery

Conversation

@KKould
Copy link
Copy Markdown
Member

@KKould KKould commented May 4, 2026

What problem does this PR solve?

Support quantified subquery predicates in WHERE, including ANY, SOME, and ALL.

IN (subquery) is handled as = ANY (subquery) so it can share the same bind/planning/execution path. EXISTS (select *) is also allowed by avoiding scalar/quantified single-column output checks for EXISTS.

Issue link:

What is changed and how it works?

  • Adds MarkApplyQuantifier::{Any, All} and models quantified predicates with MarkApplyKind::Quantified.
  • Refactors subquery binding so bind_subquery returns only the subquery plan/correlation state, while bind_subquery_with_output validates and returns the single output expression for scalar/quantified predicates.
  • Binds IN as Eq + Any, binds ANY/SOME as quantified ANY, and binds ALL as quantified ALL.
  • Extends mark apply execution so ANY and ALL share right-side scan semantics with correct TRUE/FALSE/NULL outcomes.
  • Keeps parameterized index probing only for quantified ANY; ALL uses the general scan path.
  • Adds ORM helpers such as eq_any, eq_some, lt_any, and gt_all for fields and query values, generated from a shared quantified comparison macro.
  • Opens existing SLT coverage for quantified predicates and EXISTS in SELECT/DELETE/UPDATE paths, and adds focused ANY/ALL/SOME coverage.

Code changes

  • Has Rust code change
  • Has CI related scripts change

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Manual test commands:

cargo check
cargo fmt --check
make test
cargo test -p macros-test
cargo test -p macros-test test::test_orm_expression_and_set_query_helpers
cargo test -p kite_sql binder::select::tests
cargo test -p kite_sql execution::dql::mark_apply
make test-slt SQLLOGIC_PATH=tests/slt/any_all_quantifier.slt
make test-slt SQLLOGIC_PATH=tests/slt/sql_2016/E061_07.slt
make test-slt SQLLOGIC_PATH=tests/slt/sql_2016/E061_12.slt
make test-slt SQLLOGIC_PATH=tests/slt/crdb/delete.slt
make test-slt SQLLOGIC_PATH=tests/slt/crdb/update.slt

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Note for reviewer

IN (subquery) now displays/plans through quantified ANY (MarkAnyApply) instead of the previous IN-specific mark apply naming. The execution path still preserves the existing parameterized probe fast path for equality ANY/IN predicates.

@KKould KKould self-assigned this May 4, 2026
@KKould KKould added the enhancement New feature or request label May 4, 2026
@KKould KKould linked an issue May 4, 2026 that may be closed by this pull request
@KKould KKould merged commit 3318420 into main May 4, 2026
14 checks passed
@KKould KKould mentioned this pull request May 4, 2026
50 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support quantified comparison predicates (Expr::AnyOp / Expr::AllOp)

1 participant