feat(sql): support streaming IN subqueries with mark joins - #2514
Open
ksushant6566 wants to merge 1 commit into
Open
ksushant6566 wants to merge 1 commit into
ksushant6566 wants to merge 1 commit into
Conversation
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.
Adds the remaining dynamic
IN (SELECT ...)case from #1659 through a two-input mark join in the streaming DAG. An inner insert can admit already-seen outer rows; deleting the final matching inner value retracts them. Inner duplicates preserve membership without multiplying outer rows.The join retains outer-row multiplicity and reference-counts inner values. It applies complete update/batch deltas before emitting nullable membership changes. Same-type keys use a hash index; cross-type values use Dozer's SQL equality conversions, rejecting incomparable non-null operands explicitly. The normal selection stage evaluates compound predicates and removes internal mark fields before projection or aggregation, so
SELECT *retains its original schema.The planner handles multiple and nested IN/NOT IN predicates, scalar left operands, CTEs and parenthesized UNION branches. Supporting nullable membership also required correcting AND/OR three-valued evaluation and nullable metadata. Qualified column resolution now checks the qualifier even when only one field name matches, so a correlated reference cannot silently bind to an inner column. Query-local CTE names are restored at the query boundary instead of leaking into sibling subqueries.
Scope: uncorrelated, single-column subqueries. TTL-bearing inputs are rejected before any state mutation because existing TTL index eviction emits no delete events; silently expiring membership would leave downstream rows stale. Existing ORDER BY/LIMIT restrictions remain. The prior static-list IN implementation is retained.
Demo
Watch the approximately 34-second MP4, or download the original terminal recording.
This executes the actual parser, schema validation, generated DAG and processors with in-memory source events. It shows late inner matches, duplicate suppression, atomic key updates and retractions. Run
cargo test -p dozer-sql --no-default-features in_subquery_demo -- --nocaptureto reproduce it. Details are indozer-tests/in_subquery/README.md.Validation
8b0b4cc, the new parser/DAG regression fails withUnsupportedExpression(InSubquery ...).cargo test --locked -p dozer-sql -p dozer-sql-expression --no-default-features: 238 SQL tests and 27 expression tests pass; one pre-existing SQL test remains ignored. Doc tests pass.cargo check --locked -p dozer-cli --no-default-featurespasses with Rust 1.78, including the full CLI dependency graph.cargo clippy --locked -p dozer-sql -p dozer-sql-expression --no-default-features --all-targetssucceeds with warnings, including the existing large error types. Rustfmt andgit diff --checkpass.AI assistance: implemented and tested with Codex.
Fixes #1659
/claim #1659