Skip to content

fix(e6): Samsung Tableau E'...' strings and newline stripping flags - #332

Merged
tkaunlaky-e6 merged 1 commit into
mainfrom
fix/estring-newline-flags
Oct 27, 2026
Merged

tkaunlaky-e6 merged 1 commit into
mainfrom
fix/estring-newline-flags

Conversation

@tkaunlaky-e6

Copy link
Copy Markdown

Problem

87 Samsung dashboard queries (samsung-dashboard, query history 2026-10-23) fail with PARSING_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:

AND (E'VZ_1019618,...,VZ_1019613\n' = 'All' OR GNODEB_ID IN (... explode(split(E'VZ_...\n', ',')) ...))

With SAMSUNG_TABLEAU_DASHBOARD=true the "Custom SQL Query" region is parsed as Databricks, which has no E'...' 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_DASHBOARD

Flag Where Effect
STRIP_E_STRING_PREFIX databricks.py Tokenizer (read at import) E' / e' is an extra string opener in QUOTES, so E'...' 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 from QUOTES, so no Rust, parser or generator change is needed.
STRIP_STRING_NEWLINES e6.py literal_sql (read per call) Drops line feeds from every string literal, e.g. a parameter pasted with a trailing newline ('VZ_...\n' → 'VZ_...').

Each sub-flag works only when SAMSUNG_TABLEAU_DASHBOARD=true is 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 check passes: ruff, ruff-format, mypy, and unittest with the Python and Rust tokenizers (1018 tests each).
  • New tests in tests/dialects/test_e6.py:
    • test_samsung_tableau_escape_strings:
      • all 7 escapes Tableau's Extended format writes, lowercase e' and Korean text;
      • things that must not change: the e alias, ELSE'y', LIKE'%e', DATE'...';
      • off unless both flags are set.
    • test_samsung_tableau_end_to_end: a Samsung-shaped query through split_custom_sql_alias + both regions under each flag setting.
    • test_strip_string_newlines: Databricks and Postgres strings; off unless both flags are set.
  • Replay of 806 Samsung queries (704-query corpus + Oct/May query histories) through /convert-query:
Flags Result
SAMSUNG_TABLEAU_DASHBOARD only identical to main (719 OK, 87 fail)
+ STRIP_E_STRING_PREFIX 806 OK; the 719 previously-OK outputs are byte-identical; \n kept in the 87
+ STRIP_STRING_NEWLINES 806 OK; 719 identical; \n removed in the 87

The Rust and Python tokenizers give identical output on all 806 queries in every setting.

Known limitations (same behaviour as main)

  • Apostrophe written as \' inside E'...': returns 500. The Postgres tokenizer in split_custom_sql_alias rejects it before Databricks runs.
  • E'...' in the outer Postgres query: prints unquoted.
  • '' inside a string with FIX_QUOTE_ESCAPES off: becomes CONCAT.

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 (plus STRIP_STRING_NEWLINES=true to drop the newlines). Restart after changing STRIP_E_STRING_PREFIX.

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.
@tkaunlaky-e6
tkaunlaky-e6 merged commit fb35337 into main Oct 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants