"view query" function in char editor doesn't works #35205
Replies: 1 comment
-
|
The error with the "view query" function is caused by Superset's backend failing to parse your virtual dataset SQL using the Doris dialect in the sqlglot parser. This typically happens when the query contains advanced constructs like CTEs or Jinja templating, which may not be fully supported by sqlglot for Doris. While chart creation works because the query is executed directly on the database, the "view query" feature tries to parse and format the SQL for display, and that's where it fails if the dialect support is incomplete see code details. A recent fix improved handling of Jinja template parameters in SQL parsing, which helps prevent some errors with templated queries see PR #34802, but Doris dialect support for CTEs and complex syntax may still be limited. As a workaround, try simplifying your SQL template, avoid complex CTEs or advanced Jinja logic in queries you want to display, and check if the syntax is supported by Doris in sqlglot. This limitation is in the backend parser, not the chart editor UI. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I hava a virtual dataset like this using doris database.
with cet as(
select
is_apply,
core_attachment,
english_name,
attachment_name,
attachment_number
from udesk_cargo_management
where 1=1
{% if filter_values('is_apply') %}
and is_apply in {{ filter_values('is_apply')|where_in }}
{% endif %}
)
SELECT
is_apply,
count(1)
from cet
GROUP by is_apply
I can create chart with this dataset, but the "view query" function in char editor is doesn't work.

and error log is like this:
2025-09-19 06:08:21,405:WARNING:superset.views.error_handling:SupersetErrorException
Traceback (most recent call last):
File "/app/superset/sql/parse.py", line 553, in _parse
statements = sqlglot.parse(script, dialect=dialect)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/sqlglot/init.py", line 102, in parse
return Dialect.get_or_raise(read or dialect).parse(sql, **opts)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/sqlglot/dialects/dialect.py", line 1062, in parse
return self.parser(**opts).parse(self.tokenize(sql), sql)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/sqlglot/parser.py", line 1601, in parse
return self._parse(
^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/sqlglot/parser.py", line 1673, in _parse
self.raise_error("Invalid expression / Unexpected token")
File "/app/.venv/lib/python3.11/site-packages/sqlglot/parser.py", line 1714, in raise_error
raise error
sqlglot.errors.ParseError: Invalid expression / Unexpected token. Line 1, Col: 36.
SELECT is_apply AS is_apply,
count(1)AScount(1)FROM (with cet as(
select
is_apply,
core_attachment,
english_name,
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1484, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1469, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/superset/views/base_api.py", line 120, in wraps
duration, response = time_function(f, self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/superset/utils/core.py", line 1409, in time_function
response = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/flask_appbuilder/security/decorators.py", line 109, in wraps
return f(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/superset/utils/log.py", line 304, in wrapper
value = f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File "/app/superset/sqllab/api.py", line 232, in format_sql
result = SQLScript(model["sql"], model.get("engine")).format()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/superset/sql/parse.py", line 1231, in init
self.statements = statement_class.split_script(script, engine)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/superset/sql/parse.py", line 591, in split_script
cls(ast=ast, engine=engine) for ast in cls._parse(script, engine) if ast
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/superset/sql/parse.py", line 556, in _parse
raise SupersetParseError(
superset.exceptions.SupersetParseError: Error parsing near '(' at line 1:36
180.169.129.210 - - [19/Sep/2025:06:08:21 +0000] "POST /api/v1/sqllab/format_sql/ HTTP/1.1" 422 663 "http://139.196.8.69:8088/explore/?form_data_key=Yfnn1Y_hqEA&datasource_type=table&datasource_id=21&save_action=saveas&slice_id=7" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36"
Beta Was this translation helpful? Give feedback.
All reactions