You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2021/07/21 08:48:48 UTC
[GitHub] [druid] smic-datalabs-von edited a comment on issue #10548: Plan cannot be built when using virtual column and UNION ALL in SQL query
smic-datalabs-von edited a comment on issue #10548:
URL: https://github.com/apache/druid/issues/10548#issuecomment-884010117
I encountered this error as well. I am using Superset to create a Sankey diagram. My data source for this is a virtual dataset coming from a SQL query issued on Druid that uses `UNION ALL`. Superset then treats this as a subquery and issues a GROUP BY.
This is the `UNION ALL` query similar to what I have:
```sql
SELECT
a AS column_1
, b AS column_2
, SUM(metric) AS metric
FROM table
UNION ALL
b AS column_1
, c AS column_2
, SUM(metric) AS metric
FROM table
```
In Superset, this is then placed in a subquery and GROUP BY aggregation is made:
```sql
SELECT
column_1 AS column_1
, column_2 as column_2
, SUM(metric) AS metric
FROM (
-- Place the UNION ALL query above here...
)
GROUP BY column_1, column_2
```
If the query does not contain any aggregations or GROUP BY, it succeeds. For example:
```sql
SELECT
column_1 AS column_1
, column_2 as column_2
, metric AS metric -- metric column is not aggregated
FROM (
-- Place the UNION ALL query above here...
)
-- No GROUP BY
```
I could have used the third query, but using the Sankey visual in Superset unfortunately requires the query to be like the second snippet.
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org