'How to group by DATE_TRUNC in Dremio with original column name as alias [in Superset]
I'm using Superset for BI, with a Dremio backend.
This works great, except when attempting to change the "Time Grain" of a date range selection.
In Superset, if I choose a different time grain, like "day", it correctly creates a GROUP BY modification to the native query that looks like this -
SELECT DATE_TRUNC('day', dob) AS dob,
group_name AS group_name,
location_name AS location_name,
sum(amount) AS net
FROM my_table
WHERE dob >= TO_DATE('2021-09-03', 'YYYY-MM-DD')
AND dob < TO_DATE('2021-09-10', 'YYYY-MM-DD')
GROUP BY DATE_TRUNC('day', dob),
group_name,
location_name
ORDER BY net DESC
LIMIT 10000
But that fails with Expression 'my_table.dob' is not being grouped
If I execute a query directly in Dremio and give the column a different alias, it works -
SELECT DATE_TRUNC('day', dob) AS d,
group_name AS group_name,
location_name AS location_name,
sum(amount) AS net
FROM my_table
WHERE dob >= TO_DATE('2021-09-03', 'YYYY-MM-DD')
AND dob < TO_DATE('2021-09-10', 'YYYY-MM-DD')
GROUP BY DATE_TRUNC('day', dob),
group_name,
location_name
ORDER BY net DESC
LIMIT 10000
Superset uses an alias which is the same as the original column name, so dynamically changing the datetime granularity is broken. I don't know of a way to force a different alias for the time column.
Does anyone know a workaround?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
