You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "juhoautio-rovio (via GitHub)" <gi...@apache.org> on 2023/02/08 21:58:34 UTC

[GitHub] [druid] juhoautio-rovio opened a new issue, #13775: SQL query with an empty string as group by fails: "Cannot add expression of different type to set"

juhoautio-rovio opened a new issue, #13775:
URL: https://github.com/apache/druid/issues/13775

   ### Affected Version
   
   25.0.0
   
   ### Description
   
   Having a an empty string as a value and grouping by it doesn't make much sense, but there happened to be a query like that, and it was working with Druid version 0.17.0.
   
   Now, with Druid 25.0.0 this query fails:
   ```sql
   SELECT
       '' as my_group,
       sum(double_col_1) + sum(double_col_2) as sum_double_cols
   FROM druid.my_datasource
   WHERE
       CAST(__time AS DATE) BETWEEN (DATE '2018-05-01') AND (DATE '2018-09-07')
   GROUP BY 1;
   ```
   
   The error is:
   ```
   [00000][-1] Error -1 (00000) : Error while executing SQL "SELECT
   '' as my_group,
   sum(double_col_1) + sum(double_col_2) as sum_double_cols
   FROM druid.my_datasource
   WHERE
   CAST(__time AS DATE) BETWEEN (DATE '2018-05-01') AND (DATE '2018-09-07')
   GROUP BY 1": Remote driver error: QueryInterruptedException: java.lang.AssertionError: Cannot add expression of different type to set:
   set type is RecordType(CHAR(0) NOT NULL my_group, DOUBLE NOT NULL sum_double_cols) NOT NULL
   expression type is RecordType(CHAR(0) my_group, DOUBLE NOT NULL sum_double_cols) NOT NULL
   set is rel#30743:LogicalProject.NONE.[](input=HepRelVertex#30742,my_group=$0,sum_double_cols=+($1, $2))
   expression is LogicalProject(my_group=[null:CHAR(0)], sum_double_cols=[+($1, $2)])
   LogicalAggregate(group=[{0}], agg#0=[SUM($1)], agg#1=[SUM($2)])
   LogicalProject(my_group=[''], double_col_1=[$2], double_col_2=[$1])
   LogicalFilter(condition=[AND(>=(CAST($0):DATE NOT NULL, 2018-05-01), <=(CAST($0):DATE NOT NULL, 2018-09-07))])
   LogicalProject(__time=[$0], double_col_2=[$23], double_col_1=[$31])
   LogicalTableScan(table=[[druid, my_datasource]])
   -> RuntimeException: java.lang.AssertionError: Cannot add expression of different type to set:
   set type is RecordType(CHAR(0) NOT NULL my_group, DOUBLE NOT NULL sum_double_cols) NOT NULL
   expression type is RecordType(CHAR(0) my_group, DOUBLE NOT NULL sum_double_cols) NOT NULL
   set is rel#30743:LogicalProject.NONE.[](input=HepRelVertex#30742,my_group=$0,sum_double_cols=+($1, $2))
   expression is LogicalProject(my_group=[null:CHAR(0)], sum_double_cols=[+($1, $2)])
   LogicalAggregate(group=[{0}], agg#0=[SUM($1)], agg#1=[SUM($2)])
   LogicalProject(my_group=[''], double_col_1=[$2], double_col_2=[$1])
   LogicalFilter(condition=[AND(>=(CAST($0):DATE NOT NULL, 2018-05-01), <=(CAST($0):DATE NOT NULL, 2018-09-07))])
   LogicalProject(__time=[$0], double_col_2=[$23], double_col_1=[$31])
   LogicalTableScan(table=[[druid, my_datasource]])
   -> AssertionError: Cannot add expression of different type to set:
   set type is RecordType(CHAR(0) NOT NULL my_group, DOUBLE NOT NULL sum_double_cols) NOT NULL
   expression type is RecordType(CHAR(0) my_group, DOUBLE NOT NULL sum_double_cols) NOT NULL
   set is rel#30743:LogicalProject.NONE.[](input=HepRelVertex#30742,my_group=$0,sum_double_cols=+($1, $2))
   expression is LogicalProject(my_group=[null:CHAR(0)], sum_double_cols=[+($1, $2)])
   LogicalAggregate(group=[{0}], agg#0=[SUM($1)], agg#1=[SUM($2)])
   LogicalProject(my_group=[''], double_col_1=[$2], double_col_2=[$1])
   LogicalFilter(condition=[AND(>=(CAST($0):DATE NOT NULL, 2018-05-01), <=(CAST($0):DATE NOT NULL, 2018-09-07))])
   LogicalProject(__time=[$0], double_col_2=[$23], double_col_1=[$31])
   LogicalTableScan(table=[[druid, my_datasource]])
   
   ```
   
   Replacing the `my_group` literal with a single space string makes the query pass:
   ```sql
   SELECT
       ' ' as my_group,
       sum(double_col_1) + sum(double_col_2) as sum_double_cols
   FROM druid.my_datasource
   WHERE
       CAST(__time AS DATE) BETWEEN (DATE '2018-05-01') AND (DATE '2018-09-07')
   GROUP BY 1;
   ```
   
   Also, somehow if I don't try to do any further operation on the result of sum, the query passes. For example this modification, with still an empty string for `my_group`, succeeds:
   ```sql
   SELECT
       '' as my_group,
       sum(double_col_1 + double_col_2) as sum_double_cols
   FROM druid.my_datasource
   WHERE
       CAST(__time AS DATE) BETWEEN (DATE '2018-05-01') AND (DATE '2018-09-07')
   GROUP BY 1;
   ```
   
   Other information:
   - **Cluster size:** reproduced the issue with smaller and bigger cluster
   - **Configurations in use:** I didn't change any relevant configuration when switching from 0.17.0 to 25.0.0.
   - **Steps to reproduce the problem:** I'm not sure how to best provide a full example with table creation & inserting some dummy data into it – please advise if possible?


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


Re: [I] SQL query with an empty string as group by fails: "Cannot add expression of different type to set" (druid)

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed issue #13775: SQL query with an empty string as group by fails: "Cannot add expression of different type to set"
URL: https://github.com/apache/druid/issues/13775


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


Re: [I] SQL query with an empty string as group by fails: "Cannot add expression of different type to set" (druid)

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #13775:
URL: https://github.com/apache/druid/issues/13775#issuecomment-1928547983

   This issue has been marked as stale due to 280 days of inactivity.
   It will be closed in 4 weeks if no further activity occurs. If this issue is still
   relevant, please simply write any comment. Even if closed, you can still revive the
   issue at any time or discuss it on the dev@druid.apache.org list.
   Thank you for your contributions.


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


Re: [I] SQL query with an empty string as group by fails: "Cannot add expression of different type to set" (druid)

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #13775:
URL: https://github.com/apache/druid/issues/13775#issuecomment-1979851951

   This issue has been closed due to lack of activity. If you think that
   is incorrect, or the issue requires additional review, you can revive the issue at
   any time.


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


[GitHub] [druid] juhoautio-rovio commented on issue #13775: SQL query with an empty string as group by fails: "Cannot add expression of different type to set"

Posted by "juhoautio-rovio (via GitHub)" <gi...@apache.org>.
juhoautio-rovio commented on issue #13775:
URL: https://github.com/apache/druid/issues/13775#issuecomment-1424365874

   @imSanko thank you for stepping in! I don't have permission to assign this issue to anyone.


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


[GitHub] [druid] imSanko commented on issue #13775: SQL query with an empty string as group by fails: "Cannot add expression of different type to set"

Posted by "imSanko (via GitHub)" <gi...@apache.org>.
imSanko commented on issue #13775:
URL: https://github.com/apache/druid/issues/13775#issuecomment-1424356865

   can u assign this issue to me so that I can help you to solve it.
   


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


Re: [I] SQL query with an empty string as group by fails: "Cannot add expression of different type to set" (druid)

Posted by "juhoautio-rovio (via GitHub)" <gi...@apache.org>.
juhoautio-rovio commented on issue #13775:
URL: https://github.com/apache/druid/issues/13775#issuecomment-1980309240

   I don't have latest version of Druid at hand to test, but I suspect that this bug remains.


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