Repository navigation
fix(convert): refuse == and convert TOP and FETCH FIRST to LIMIT - #183
Merged
Merged
Conversation
kvlonge
force-pushed
the
fix/snowflake-clause-keyword-columns
branch
from
November 11, 2026 19:10
a54615e to
3eea2bc
Compare
kvlonge
force-pushed
the
feat/convert-top-fetch-refuse-double-equals
branch
from
November 11, 2026 21:24
56c935b to
a0dba58
Compare
Base automatically changed from
fix/snowflake-clause-keyword-columns
to
main
November 11, 2026 23:30
Snowflake parses == and then rejects it when compiling, as a call to an unknown function (errno 2139, recorded in the everyday corpus for WHERE status == 'shipped'). SQLQuack read it as = and converted it. A check finding now names it "Unknown function ==" with help to compare with =, and refuses the statement before conversion. Parsing still accepts it, as Snowflake does.
TOP n and FETCH { FIRST | NEXT } n { ROW | ROWS } [ ONLY ] keep the first n
rows exactly as LIMIT n does, after ORDER BY and DISTINCT. The recorded
top-n and limit.fetch cases now replay as matching. PERCENT, WITH TIES and
a query that combines LIMIT, TOP or FETCH stay refused, since LIMIT cannot
express them.
…ke rejects it The analysis test still expected TOP to be refused as a missing rule. TOP now converts as LIMIT, TOP PERCENT is refused, and == is refused before conversion.
kvlonge
force-pushed
the
feat/convert-top-fetch-refuse-double-equals
branch
from
November 11, 2026 23:33
a0dba58 to
1fd11a5
Compare
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
Three demo queries came out wrong.
==converted to=although Snowflake rejects it, andTOP nandFETCH FIRST n ROWS ONLYwere refused although LIMIT expresses them exactly.Changes
==is now a check finding, SQ0206double_equals, worded as Snowflake reports it: "Unknown function ==", with help to compare with=. Snowflake parses==and rejects it when compiling (errno 2139, recorded incorpora/everyday/snowflake-receipts.json), so parsing still accepts it, and the finding refuses the statement before conversion. The diagnostics reference is regenerated.TOP nandFETCH { FIRST | NEXT } n { ROW | ROWS } [ ONLY ]convert toLIMIT n, after ORDER BY and DISTINCT. PERCENT, WITH TIES, a count that is not an integer literal, and more than one of LIMIT, TOP and FETCH stay refused.Converted SQL in the playground corpora (basics, everyday, everyday-models, examples), before and after. Only these 3 of 2,962 statements change:
SELECT TOP 5 * FROM ordersSELECT ... FROM "ORDERS" AS "ORDERS" LIMIT 5SELECT order_id FROM orders FETCH FIRST 10 ROWS ONLYSELECT "ORDERS"."ORDER_ID" AS "ORDER_ID" FROM "ORDERS" AS "ORDERS" LIMIT 10SELECT order_id FROM orders WHERE status == 'shipped'= 'shipped'Verification
top-nandlimit.fetchcases go from refused to matching, and their 8 obligations are met. 0 regressions. The translation results and SQL size baselines are re-recorded.==as an operator.==rejections and non-rejections (strings, comments,>=,!=),checkexiting 1 with SQ0206, TOP/FETCH rows run on DuckDB, and the PERCENT, WITH TIES and TOP-with-LIMIT refusals.make check-cipasses.