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/08/12 23:10:17 UTC

[GitHub] [druid] paul-rogers opened a new issue #11586: Query with COUNT(*), nested sub-query returns no results.

paul-rogers opened a new issue #11586:
URL: https://github.com/apache/druid/issues/11586


   ### Affected Version
   
   The Druid version where the problem was encountered.
   ### Description
   
   Consider the "stock" Wikipedia data source and stock Docker Druid cluster. Version: 0.21.
   
   The query is designed to identify the number of rows that would result from building a new roll-up table with just three of the dimensions:
   
   ```sql
   SELECT COUNT(*)
   FROM (
     SELECT hr, channel, page, COUNT(*) AS cnt
     FROM (
       SELECT
         DATE_TRUNC('hour', __time) AS hr,
         channel,
         page
       FROM "wikiticker-2015-09-12-sampled"
     )
     GROUP BY hr, channel, page
   )
   ```
   
   The query returns zero rows.
   
   However, replace the `count(*)` with `*` and we get many rows of results. (The rows give the expected number of rows per group in the new roll-up datasource.) Since a `SELECT *` query returns rows, expected the `COUNT(*)` to count those rows.
   
   A workaround is to use the form which works, and to count the rows in the client.


-- 
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] SharuBob commented on issue #11586: Query with COUNT(*), nested sub-query returns no results

Posted by GitBox <gi...@apache.org>.
SharuBob commented on issue #11586:
URL: https://github.com/apache/druid/issues/11586#issuecomment-899754077


   @paul-rogers did you find any solution for the above issue. Looks like I have reported more or less same issue [here](https://github.com/apache/druid/issues/11603)


-- 
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] paul-rogers commented on issue #11586: Query with COUNT(*), nested sub-query returns no results

Posted by GitBox <gi...@apache.org>.
paul-rogers commented on issue #11586:
URL: https://github.com/apache/druid/issues/11586#issuecomment-902295161


   @SharuBob, thanks for pointing out the related issue. As it turns out, the query I'm using has no `HAVING` clause. In my case, the issue seems related to the nested queries. However, you may be right that both are symptoms of the same underlying issue, perhaps in the Calcite planner.
   
   The solution I used is simply to omit the outer `COUNT(*)` and have the client do the counting. Doing so is inefficient, and may not scale to huge data sets. But, it was a quick & dirty work-around for my specific use case. 


-- 
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] kxbin edited a comment on issue #11586: Query with COUNT(*), nested sub-query returns no results

Posted by GitBox <gi...@apache.org>.
kxbin edited a comment on issue #11586:
URL: https://github.com/apache/druid/issues/11586#issuecomment-1017255778


   **I found that if the dataset is 0 rows**
   
   **The result of count(*) is not 0, but returned no data.**
   
   ![image](https://user-images.githubusercontent.com/17782922/150307077-85e8b016-5464-4113-a8aa-f11f0d77c9cc.png)
   
   
   druid version is 0.20.0


-- 
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] SharuBob commented on issue #11586: Query with COUNT(*), nested sub-query returns no results

Posted by GitBox <gi...@apache.org>.
SharuBob commented on issue #11586:
URL: https://github.com/apache/druid/issues/11586#issuecomment-902451119


   @paul-rogers Thank you for the reply again. Even I have made more or less same short term work around, will still use subquery to fetch one of the columns and then do the len(array) at client side to get the count. 
   
   Hope this will be addressed in the coming days. 🙏 


-- 
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] kxbin commented on issue #11586: Query with COUNT(*), nested sub-query returns no results

Posted by GitBox <gi...@apache.org>.
kxbin commented on issue #11586:
URL: https://github.com/apache/druid/issues/11586#issuecomment-1017255778


   **I found that if the dataset is 0 rows**
   
   **The result of count(*) is not 0, but returned no data.**
   
   ![image](https://user-images.githubusercontent.com/17782922/150307077-85e8b016-5464-4113-a8aa-f11f0d77c9cc.png)
   


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