rusackas commented on issue #38009:
URL: https://github.com/apache/superset/issues/38009#issuecomment-4949829248
Nice writeup @goldjee, the fix options at the bottom are basically the map
here.
Digging into where we stand: #41125 (which was actually for #36113) covers
part of this. It stopped `sanitize_clause` from round-tripping adhoc
expressions through sqlglot, so a `U&'...'` literal in a metric/column/adhoc
filter is now returned verbatim and survives. The basic virtual-dataset repro
in this issue is OK too, but that one's from #38683 ('apply RLS
conservatively'), which only regenerates the FROM clause when RLS was actually
applied.
So the common cases are handled by *avoiding* the re-render. What's still
broken is anywhere sqlglot genuinely has to regenerate the SQL: a virtual
dataset (or adhoc clause) with RLS actually applied, cross-dialect
transpilation, or a clause that contains a comment (that last one takes
`sanitize_clause`'s re-render branch). Those still come back as `U & '...'` and
break.
The root cause is upstream and still unfixed. I checked the latest sqlglot
(30.12.0, and we're pinned `<31`) and Postgres `U&'\FE01'` still tokenizes as
`U` + `&`. sqlglot does have a `UNICODE_STRING` token and a `UnicodeString`
expression, and it supports this for Trino/Snowflake, but the Postgres
dialect's `UNICODE_STRINGS` list is empty, so `U&` was never wired up there. A
version bump won't help until that lands.
So I don't think a Superset feature PR is the right shape for the real fix.
The clean path is upstream: teach sqlglot's Postgres dialect to
tokenize/generate `U&'...'` (the scaffolding is already there for other
dialects), then we bump once it's released. If we need relief sooner, the
interim option is a mask/restore shim around our sqlglot round-trips (protect
the literal before parse, restore after generate) so the RLS/transpile paths
survive, but I'd rather not take on more SQL string-munging than we have to,
which your own note calls out. Keeping this open.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]