Repository navigation
fix(e6): Tableau E'...' strings in Postgres regions of the subquery tree - #340
Merged
Merged
Conversation
Under SUBQUERY_TREE a Custom SQL region without backticks parses as Postgres, so a Tableau
parameter E'...\n' became a Postgres byte string that e6 printed bare (engine: Lexical error
on "\"). With (SAMSUNG_TABLEAU_DASHBOARD, SUBQUERY_TREE or SUBQUERY_TREE_MULTIDIALECT) +
STRIP_E_STRING_PREFIX, emit it as a quoted string with its escapes decoded as Postgres does;
STRIP_STRING_NEWLINES then drops the newline, as on the Databricks path.
The tree's structural tokenize also treats a backslash as a string escape, so a
backslash-escaped quote ('O\'Brien', E'O\'Brien') no longer ends a string early and fails
the request.
suyashkhare1403
previously approved these changes
Nov 20, 2026
…f a regex decoder Replace the e6 bytestring_sql regex decoder with the same tokenizer setting the Databricks fix uses: under (SAMSUNG_TABLEAU_DASHBOARD, SUBQUERY_TREE or SUBQUERY_TREE_MULTIDIALECT) + STRIP_E_STRING_PREFIX the Postgres tokenizer reads E'...' as a plain quote with backslash escapes, and sqlglot decodes them (Python and Rust tokenizers). The flag is read at import, so the tests run in a subprocess.
suyashkhare1403
approved these changes
Nov 20, 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.
Problem
Samsung Tableau queries failed with
PARSING_FAILED(20 Nov: 27 failures, 9 distinct queries):Tableau's Postgres connector sends a parameter as
E'135030,...,135998\n'. UnderSUBQUERY_TREEeach region is Postgres unless it fails the Postgres parse. This Custom SQL has no backticks, so it parses as Postgres,E'...'becomes a Postgres byte string, and e6 printed it bare with the raw\n:STRIP_E_STRING_PREFIX(#332/#339) only set up the Databricks tokenizer. That is whySAMSUNG_TABLEAU_DASHBOARD(Custom SQL always read as Databricks) and queries with backticks worked.Fix
postgres.py: the same tokenizer setting as the Databricks fix. With (SAMSUNG_TABLEAU_DASHBOARD,SUBQUERY_TREEorSUBQUERY_TREE_MULTIDIALECT) +STRIP_E_STRING_PREFIX, the Postgres tokenizer readsE'...'as a plain quote with\as a string escape. sqlglot then decodes the escapes in both the Python and Rust tokenizers.STRIP_STRING_NEWLINESdrops the newline, giving the same output as the Databricks path:subquery_tree.py: the structural tokenize treats\as a string escape. Before, a backslash-escaped quote (Databricks'O\'Brien', TableauE'O\'Brien') ended a string early and the request failed with a 500 underSUBQUERY_TREE. Each region still tokenizes in its own dialect.Testing
make style,make test(Rust and Python tokenizers) andmake test-multidialectall pass.test_postgres_tableau_escape_strings(every Tableau escape, flag gating, newline stripping), the Postgres-region path underSUBQUERY_TREEandSUBQUERY_TREE_MULTIDIALECT, and backslash-escaped quotes.SUBQUERY_TREE+ both strip flags (Samsung prod)SUBQUERY_TREE_MULTIDIALECT+ both strip flagsSAMSUNG_TABLEAU_DASHBOARD+ both strip flagsSUBQUERY_TREEonlyThe 82 Conde Nast changes are all backslashes in Databricks strings that the tree read as Postgres. They now follow Databricks semantics, e.g. regex
'(\\?.*paid-revops)'keeps one backslash instead of being doubled. These only change under the Tableau flags, which Conde Nast does not set.E'VZ_1,VZ_2\n'VZ_1,VZ_2, length 9E'a\tb',E'a\rb'E'C:\\tmp'C:\tmpE'O\'Brien',E'O''Brien'O'BrienIN (...)/= 'All''(\\?.*paid-revops)'on a URL without?The 20 Nov queries now get past parsing (they only fail locally on the missing
dltcatalog).Deployment
No config change. The Samsung config already sets
SUBQUERY_TREE,STRIP_E_STRING_PREFIXandSTRIP_STRING_NEWLINES.Known limitation
With these flags, plain Postgres strings also use backslash escapes, so a hand-written
'C:\'would fail. Tableau sends backslashes only insideE'...', and none of the replayed queries contain such a string.