[ 
https://issues.apache.org/jira/browse/CASSANDRA-13411?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15983248#comment-15983248
 ] 

Benjamin Lerer commented on CASSANDRA-13411:
--------------------------------------------

For queries without GROUP BY but with aggregates in the selection clause, we 
will always return one row even if no data is actually fetched.

The reason comes from queries like {{SELECT COUNT(id) FROM table WHERE id = 
"13411"}} where you expect {{0}} to be returned when there are no rows.

I guess the surprising part is that the returned value for the {{id}} column is 
{{null}} but, when a column is specified without aggregation function in an 
aggregation query, C* treat is as if it was {{FIRST(<column_name>)}}. So, in my 
opinion the result is really the expected one even if it is surprising.

> CQL query using the MAX function returns resultset with Row(null, null ...) 
> if data is not found
> ------------------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-13411
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-13411
>             Project: Cassandra
>          Issue Type: Bug
>          Components: CQL
>         Environment: 3.10
>            Reporter: Andrew Efimov
>            Priority: Minor
>
> CQL query using the MAX function returns resultset with rows.size=1 if data 
> is not found. And Row has only null values.
> {{SELECT id, value, MAX(date) FROM table WHERE id = "13411"}}
> If table does not have row by {{id = "13411"}} then session returns ResultSet 
> with Rows.size = 1 and Row(null, null, null).
> This is a problem to determine whether or not a data has actually been exist.
> I did not check other aggregation functions.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to