kfrydel opened a new issue, #37285:
URL: https://github.com/apache/superset/issues/37285

   ### Bug description
   
   The following query:
   ```
     select
       groupConcat(', ')(part_name) as concatenated
     from system.parts
   ```
   when run in SQL Lab on a ClickHouse connection, it returns the following 
error:
   ```
   ClickHouse Connect (Superset) Error: clickhousedb error: Error parsing near 
'as' at line 2:32
   This may be triggered by:
   Issue 1002 - The database returned an unexpected error.
   ```
   indicating that the ClickHouse DB returned an error. However, the query runs 
fine in the ClickHouse client.
   The connections has `Allow DDL and DML` flag set to true in Advanced -> SQL 
Lab.
   When `Allow DDL and DML` is unchecked, the error looks like this:
   ```
   Unable to parse SQL:
   Error parsing near 'as' at line 2:32
       groupConcat(', ')(part_name) as concatenated
                                  ^
   
   
   DB engine Error: This database does not allow for DDL/DML, and the query 
could not be parsed to confirm it is a read-only query. Please contact your 
administrator for more assistance.
   See more
   ```
   
   Here is the syntax of the aggregate function: 
https://clickhouse.com/docs/sql-reference/aggregate-functions/reference/groupconcat
 (there are more functions like this) so it seems that double pair of 
parenthesis is an problem for Superset.
   
   There is a similar ticket (https://github.com/apache/superset/issues/31674), 
but it seems that the exact problem was not pinpointed and was closed as stale.
   
   ### Screenshots/recordings
   
   Error when  `Allow DDL and DML`  is false:
   <img width="2100" height="708" alt="Image" 
src="https://github.com/user-attachments/assets/88e66bc5-a3dd-4193-aa16-e6460db004cc";
 />
   when true:
   
   <img width="2086" height="582" alt="Image" 
src="https://github.com/user-attachments/assets/c7bcf183-7dea-4eb2-b60e-75051340cf6b";
 />
   
   ### Superset version
   
   5.0.0
   
   ### Python version
   
   3.11
   
   ### Node version
   
   I don't know
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   ```
   2026-01-20 
15:05:12,978:WARNING:superset.views.error_handling:SupersetErrorsException
   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/.venv/lib/python3.11/site-packages/flask_appbuilder/security/decorators.py",
 line 109, in wraps
       return f(self, *args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^
     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 1369, in time_function
       response = func(*args, **kwargs)
                  ^^^^^^^^^^^^^^^^^^^^^
     File "/app/superset/views/base_api.py", line 92, 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 409, in execute_sql_query
       command_result: CommandResult = command.run()
                                       ^^^^^^^^^^^^^
     File "/app/superset/utils/decorators.py", line 266, in wrapped
       return on_error(ex)
              ^^^^^^^^^^^^
     File "/app/superset/utils/decorators.py", line 236, in on_error
       raise ex
     File "/app/superset/utils/decorators.py", line 259, in wrapped
       result = func(*args, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^
     File "/app/superset/commands/sql_lab/execute.py", line 105, in run
       status = self._run_sql_json_exec_from_scratch()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "/app/superset/commands/sql_lab/execute.py", line 158, in 
_run_sql_json_exec_from_scratch
       return self._sql_json_executor.execute(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "/app/superset/sqllab/sql_json_executer.py", line 110, in execute
       raise SupersetErrorsException(
   superset.exceptions.SupersetErrorsException: 
[SupersetError(message="clickhousedb error: Error parsing near 'as' at line 
2:32", error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR: 
'GENERIC_DB_ENGINE_ERROR'>, level=<ErrorLevel.ERROR: 'error'>, 
extra={'engine_name': 'ClickHouse Connect (Superset)', 'issue_codes': [{'code': 
1002, 'message': 'Issue 1002 - The database returned an unexpected error.'}]})]
   192.168.11.3 - - [20/Jan/2026:15:05:12 +0000] "POST /api/v1/sqllab/execute/ 
HTTP/1.1" 500 306 "http://192.168.11.83:8088/sqllab/"; "Mozilla/5.0 (X11; Linux 
x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36"
   ```
   
   ### Checklist
   
   - [x] I have searched Superset docs and Slack and didn't find a solution to 
my problem.
   - [x] I have searched the GitHub issue tracker and didn't find a similar bug 
report.
   - [x] I have checked Superset's logs for errors and if I found a relevant 
Python stacktrace, I included it here as text in the "additional context" 
section.


-- 
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]

Reply via email to