Repository navigation
fix(e6): SUBQUERY_TREE runs every query through the tree; skip JOIN ON/USING in LiteParser - #337
Merged
Merged
Conversation
…N/USING in LiteParser - SUBQUERY_TREE=true now sends every /convert-query request through the subquery tree, whether or not the planner sends the MULTIDIALECT feature flag. - LiteParser no longer parses a JOIN's ON condition or USING list. A backtick there (e.g. CAST(u.`x` AS INT)) failed the lite parse with "Expected AS after CAST", or ended it early so later JOIN subqueries were missed.
suyashkhare1403
approved these changes
Nov 17, 2026
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.
What
SUBQUERY_TREE=truenow sends every query through the subquery tree, whether or not the planner sends theMULTIDIALECTfeature flag. The planner doesn't need to know if a query is single or multi-dialect: a single-dialect query is just a tree whose regions all parse the same way. WithSUBQUERY_TREEoff, nothing changes.LiteParserno longer parses a JOIN'sONcondition orUSINGlist. It already skipped the SELECT list and WHERE etc.;ON/USINGwere the last value expressions it parsed with the generic tokenizer. A backtick there broke it:JOIN u ON CAST(u.`x` AS INT) = t.idfailed withExpected AS after CAST.ONended the parse early, so a subquery joined after it was silently missed.Evidence (nov_4th medium dump, pure Databricks, 13,397 unique queries)
Subtree (no
MULTIDIALECTflag) vs plainfrom_sql=databricks:ONbug.CAST(x AS DATE)vsDATE(x), which give the same result on e6.SHOW/DESCRIBE.Tests
tests/test_subquery_tree.py:ON,COALESCEinON,USING (...),LEFT(...)as a function, and a subquery joined after them;SUBQUERY_TREEalone triggers the tree;make test(1063 OK),make test-rs(1063 OK),make test-multidialect(Samsung / Condé Nast / OneTrust): OK.sqlglot/_version.py, unrelated to this change.Notes
SUBQUERY_TREE=truethe multidialect branch also takesPOWERBI_SF_TO_DBRrequests, since it is checked first.INNER_DIALECT(defaultdatabricks). If the planner stops sending flags, non-Databricks deployments would need that default to come fromfrom_sql.Timing (sequential, one process, all 14,840 rows of the dump)
Each row is sent once in each mode, alternating;
from_sql=databricks, noMULTIDIALECTflag, logging off.SUBQUERY_TREEThat is +2.9 ms per query on average (median +1.7 ms), about 20% more in total. The gap grows with query size: +0.7 ms under 2k chars, +14 ms over 50k chars.