Open gaoyan1998 opened 4 months ago
To address the issue of Superset automatically appending SEPARATOR ','
to GROUP_CONCAT
, you can use the SQL_QUERY_MUTATOR
function in the superset/config.py
file. This function allows you to modify the SQL query before it is executed, enabling you to remove the SEPARATOR ','
clause from GROUP_CONCAT
functions.
Here is how you can modify the SQL_QUERY_MUTATOR
function in your superset/config.py
:
Edit superset/config.py
:
Add the following code to define a custom SQL_QUERY_MUTATOR
function that removes the SEPARATOR ','
clause from GROUP_CONCAT
:
import re
from typing import Any
def SQL_QUERY_MUTATOR(sql: str, **kwargs: Any) -> str:
# Remove SEPARATOR ',' from GROUP_CONCAT
sql = re.sub(r'GROUP_CONCAT\((.*?)\s+SEPARATOR\s*,\s*\'\'\)', r'GROUP_CONCAT(\1)', sql, flags=re.IGNORECASE)
return sql
Restart Superset: After making this change, restart your Superset instance to apply the new configuration.
This function uses a regular expression to find instances of GROUP_CONCAT
with the SEPARATOR ','
clause and removes the SEPARATOR ','
part. This way, the modified SQL query will not include the SEPARATOR ','
clause, preventing query errors in both Doris and MySQL.
To continue the conversation, mention @dosu.
CC @liujiwen-up
Bug description
superset modifies GROUP_CONCAT when creating charts by adding the SEPARATOR ',' syntax at the end, but this is not supported in Doris. This happens not only in Doris, also in mysql, so it can be reproduced using mysql.
How to reproduce the bug
GROUP_CONCAT has
SEPARATOR ','
automatically added to it, resulting in a query error.Screenshots/recordings
No response
Superset version
master / latest-dev
Python version
3.9
Node version
16
Browser
Chrome
Additional context
No response
Checklist