Repository navigation
fix(e6): Samsung Tableau E'...' strings and newline stripping flags - #332
Merged
Merged
Conversation
Samsung's Tableau connects through the Postgres connector, which binds a parameter value holding a control char, quote or backslash into the Databricks Custom SQL as a Postgres escape string, e.g. E'VZ_1,VZ_2\n'. The Databricks parse of the "Custom SQL Query" region failed, so 87 dashboard queries fell back to the planner and failed. Two independent sub-flags, each active only with SAMSUNG_TABLEAU_DASHBOARD: - STRIP_E_STRING_PREFIX: the Databricks tokenizer accepts E'/e' as a string opener, so E'...' is read as a plain string. Databricks strings decode the same backslash escapes, so the value is unchanged. Read at import. - STRIP_STRING_NEWLINES: the e6 generator drops line feeds from every string literal (e.g. a parameter pasted with a trailing newline). Read per call.
gauravdawar-e6
approved these changes
Oct 27, 2026
This was referenced 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
87 Samsung dashboard queries (
samsung-dashboard, query history 2026-10-23) fail withPARSING_FAILED/Lexical error ... Encountered: ""`.Samsung's Tableau connects through the Postgres connector (
format-string-literal='Extended'). It binds a parameter value holding a control char, quote or backslash into the Databricks Custom SQL as a Postgres escape string:With
SAMSUNG_TABLEAU_DASHBOARD=truethe"Custom SQL Query"region is parsed as Databricks, which has noE'...'syntax (ParseError: Expecting )). The planner then falls back to the raw query and fails on the first backtick.Fix: two independent sub-flags under
SAMSUNG_TABLEAU_DASHBOARDSTRIP_E_STRING_PREFIXdatabricks.pyTokenizer (read at import)E'/e'is an extra string opener inQUOTES, soE'...'is read as a plain string. Databricks strings already decode the same backslash escapes (\n,\t,\\,\', ...), so the value is unchanged. Both tokenizers get it fromQUOTES, so no Rust, parser or generator change is needed.STRIP_STRING_NEWLINESe6.pyliteral_sql(read per call)'VZ_...\n'→'VZ_...').Each sub-flag works only when
SAMSUNG_TABLEAU_DASHBOARD=trueis also set. Either one alone, or the Samsung flag alone, leaves behaviour identical to main.Upstream sqlglot has neither feature: it reads
E'...'only in Postgres/DuckDB/SingleStore and has no newline stripping.Testing
make checkpasses: ruff, ruff-format, mypy, andunittestwith the Python and Rust tokenizers (1018 tests each).tests/dialects/test_e6.py:test_samsung_tableau_escape_strings:e'and Korean text;ealias,ELSE'y',LIKE'%e',DATE'...';test_samsung_tableau_end_to_end: a Samsung-shaped query throughsplit_custom_sql_alias+ both regions under each flag setting.test_strip_string_newlines: Databricks and Postgres strings; off unless both flags are set./convert-query:SAMSUNG_TABLEAU_DASHBOARDonlySTRIP_E_STRING_PREFIX\nkept in the 87STRIP_STRING_NEWLINES\nremoved in the 87The Rust and Python tokenizers give identical output on all 806 queries in every setting.
Known limitations (same behaviour as main)
\'insideE'...': returns 500. The Postgres tokenizer insplit_custom_sql_aliasrejects it before Databricks runs.E'...'in the outer Postgres query: prints unquoted.''inside a string withFIX_QUOTE_ESCAPESoff: becomesCONCAT.None of these occur in the Samsung data: no string value in the 806 queries contains an apostrophe, and all 174 newline strings are inner
E'...'parameters. The upstream-port version that also handles the first two is kept on the closed #330 for reference.Deployment
Set on the Samsung transpiler:
SAMSUNG_TABLEAU_DASHBOARD=true STRIP_E_STRING_PREFIX=true(plusSTRIP_STRING_NEWLINES=trueto drop the newlines). Restart after changingSTRIP_E_STRING_PREFIX.