[teiid-issues] [JBoss JIRA] (TEIID-2983) MongoDB: Function "count()" returns sum instead of number of rows

Ramesh Reddy (JIRA) issues at jboss.org
Thu Jun 5 07:04:15 EDT 2014


    [ https://issues.jboss.org/browse/TEIID-2983?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12973686#comment-12973686 ] 

Ramesh Reddy commented on TEIID-2983:
-------------------------------------

Is there a way re-write multiple aggregate statement above? right now I can only think that that needs to split into two statements.

MongoDB can group by multiple elements in a group, then we can do a sum like

{code}
{$group:{ "_id" : {col1:"foo", col2:"foo2"} , "_m0" : { "$sum" : 1}}}
{code}

but not sure the it equals to 

select count(foo1), count(foo2) from bar

Right now I set to ignore the second aggregation on hind sight, but may be I can throw an exception in that case to show translator does not have support. I probably should also support DISTINCT case there.

> MongoDB: Function "count()" returns sum instead of number of rows
> -----------------------------------------------------------------
>
>                 Key: TEIID-2983
>                 URL: https://issues.jboss.org/browse/TEIID-2983
>             Project: Teiid
>          Issue Type: Bug
>          Components: Misc. Connectors
>    Affects Versions: 8.7.1
>            Reporter: Van Halbert
>            Assignee: Ramesh Reddy
>              Labels: Beta1
>             Fix For: 8.7.1, 8.8
>
>
> Function "count()" returns sum of rows instead of number of rows
> Query [1] returns sum of values of all rows of IntKey column.
> Query [2] correctly returns number of rows
>  
> [1] SELECT COUNT(IntKey) FROM BQT1.SmallA 
> [2] SELECT COUNT(*) FROM BQT1.SmallA



--
This message was sent by Atlassian JIRA
(v6.2.3#6260)


More information about the teiid-issues mailing list