Repository navigation
fix: bind subqueries outside DuckDB lambdas and keep strict divergence refusals SQ0008 - #92
Merged
Merged
Conversation
… SQ0008 WIP backup, not gated. Built and spot-checked locally only; the CLI and corpus tests are not yet run, and the branch still needs a merge of main (fensu reports conversion/constants.rs over its line limit until then). - A subquery value a rule wraps in a DuckDB lambda is bound once outside every lambda. A subquery reading the lambda's parameter, or one that may call a volatile function, refuses as SQ0005 at the subquery instead. - Refused divergences re-wrapped as type conditions keep SQ0008, so strict numeric_range refusals get policy help. - test_composition compares time growth between depths, not an absolute wall-clock bound.
…rectly Run rustfmt over the new lambda-binding code, and have the composition test assert against its expected_max_time_ratio field directly.
…ergences The subquery operand cases end in ORDER BY, so they declare an ordered result. Strict-mode refusals of numeric_range, date_text_spelling and session_timezone_utc now report a refused divergence, so the analysis tests expect that category. The lookback value test reads its count as text.
Snowflake results for the two cases in cases/temporal/subquery_operands.toml at 3287352.
The two recorded subquery operand cases return Snowflake's rows, so the translation baseline gains them as matching. No other entry moves.
Contributor
Author
|
Gate for landing at exactly
|
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.
Why
The most common incremental filter,
WHERE t >= DATEADD(DAY, -3, (SELECT MAX(t) FROM events)), emitted DuckDB SQL that DuckDB can't bind. The DATEADD emission wraps its operand in a lambda, and DuckDB refuses subqueries inside lambdas. The statement was then refused as SQ0002 with "no verified rule converts", spanning the whole statement. Separately, under--strict,numeric_rangerefusals reported SQ0003 with schema help, when every other refused divergence reports SQ0008 with policy help.Changes
check_printed) before it is returned, and any rule whose SQL fails to bind is refused rather than emitted. That stays unchanged.numeric_rangereports SQ0008 with policy help.test_compositioncompares time growth between depths instead of asserting an absolute wall-clock bound, which failed on loaded runners.Verification
numeric_rangeSQ0008 help case; a value test running the lookback on DuckDB. The strict-mode analysis tests now expect DivergenceRefused.cases/temporal/subquery_operands.toml, recorded on Snowflake. Both cases match, and the translation baseline gains exactly those 2 entries.make check-ci RECORDER=0andfensu checkpass, and the hygiene scan is clean. The gate on the exact head is recorded in a PR comment.