feat(sql): support incremental IN subqueries - #2523
Open
QIU-Guanzong wants to merge 5 commits into
Open
QIU-Guanzong wants to merge 5 commits into
QIU-Guanzong wants to merge 5 commits into
Conversation
|
|
Author
|
Sure |
This branch has not been deployed
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.
/claim #1659
This adds the remaining dynamic
IN (SELECT ...)path. For example, an outer row that arrives before its matching inner value is emitted when that value is inserted, then retracted when its last inner match is deleted. Outer updates, duplicate values, NULLs and empty inner results follow the same streaming path.The planner connects a two-input membership stage to the existing WHERE processor. It retains outer-row multiplicity, counts inner values, and removes the internal nullable membership column before projection. The implementation covers IN/NOT IN within compound predicates, scoped CTEs, multiple/nested subqueries, deterministic single-column expressions, UNION, grouped aggregates and joins.
The tests exercise SQL parsing, DAG schema propagation and the real processor factories using synthetic source events. They also cover three-valued Boolean logic, qualified-name binding, exact row representation, both shared-source fanout orders, and explicit rejection of query shapes the existing engine cannot replay correctly.
Validation
cargo fmt --all -- --checkandgit diff --checkpass; the six-event demo also passes on the submitted commit.dozer-typeswarnings. With--no-deps, two existing lints remain (unnecessary_to_ownedandlegacy_numeric_constants); allowing only those two categories passes. Full workspace/all-feature CI has not been run locally. The additional native localhost connector check below uses the default CLI.cargo +1.79.0 test --locked -p dozer-sql -p dozer-sql-expression --no-default-features --libThe local run used macOS and an existing protoc 29.3 installation. Cargo.lock and dependencies are unchanged.
Native CLI check
The default-feature CLI build also passes on the same submitted commit. Its real Webhook connector and asynchronous runtime processed 26 synthetic localhost requests across separate IN and NOT IN runs. A snapshot oracle matched every cumulative insertion stream logged by the native Dummy sink, including duplicate inner values, NULL/empty cases, batches, and deletion followed by reinsertion. Both processes shut down with exit 0 and closed their listeners.
The Dummy sink logs inserts only, so this additional run does not directly observe output retractions or claim recovery/performance coverage. The library tests above verify the full emitted operation stream. Reproduction script, configuration, transcript and verification record.
Demo
Watch the six-event demo · Transcript and SHA-256 manifest
The video is a paced rendering of actual output from the SQL-to-DAG demo below. It uses synthetic events and a synchronous test queue; it does not claim validation of live connectors, the full asynchronous executor, or restart recovery.
cargo +1.79.0 test --locked -p dozer-sql --no-default-features --lib \ tests::in_subquery::membership_demo_with_synthetic_rows -- --exact --nocaptureLimits
Correlated and multi-column subqueries are rejected. SELECT DISTINCT, global aggregates without GROUP BY, unsupported query modifiers, volatile expressions on membership-dependent paths, and TTL rows without explicit deletions are also rejected. Membership-dependent UNION DISTINCT rejects the opt-in probabilistic set mode because it cannot reliably reproduce retracted row representations. Internal field-name collisions produce an error. Inner membership changes currently scan the retained outer rows; no performance or recovery guarantee is claimed.
AI assistance: implementation, tests and source reviews were prepared with OpenAI Codex; Claude Code also reviewed the additional CLI verification harness.