Tested Aqua Data Studio Aqua Data Studio 14.0.0-rc-8 Build #: 33812 on Ubuntu 12.04( Mongo DB 2.4.3)
Normaly when DISTINCT used in the aggregation functions error message appears:
SELECT sum(distinct valuation) FROM baseaball
-- sum() called with wrong argument type
go
But when COUNT( distinct) also appears in the query this error suppresed and <null> result returned. Better give error message than return wrong result.
SELECT sum(distinct valuation), count(distinct valuation) FROM baseaball
-- sum(distinct valuation) count(distinct valuation)
------------------------------------ ----------------------------------
-- ( null) 1
The error message displayed for the first scenario is now also displayed when the COUNT(DISTINCT <field>)
expression is present.
Verified in Aqua Data Studio Aqua Data Studio 14.0.0-rc-13 Build #: 33892 on Ubuntu 12.04( Mongo DB 2.4.3)
Still problem if count( distinct valuation) change on just distinct valuation or distinct for 2 or more fields
SELECT distinct valuation, sum(distinct valuation) FROM baseaball
-- distinct valuation sum(distinct valuation)
------------------------------------ ----------------------------------
-- 1 (null)
go
SELECT sum(distinct valuation), distinct valuation FROM baseaball
--NoViableAltException
go
SELECT distinct valuation, distinct city FROM baseaball
--NoViableAltException
go
Verified in Aqua Data Studio Aqua Data Studio 14.0.0-rc-13 Build #: 33892 on Ubuntu 12.04( Mongo DB 2.4.3)
Still problem if count( distinct valuation) change on just distinct valuation or distinct for 2 or more fields
SELECT distinct valuation, sum(distinct valuation) FROM baseaball
-- distinct valuation sum(distinct valuation)
------------------------------------ ----------------------------------
-- 1 (null)
go
SELECT sum(distinct valuation), distinct valuation FROM baseaball
--NoViableAltException
go
SELECT distinct valuation, distinct city FROM baseaball
--NoViableAltException
go
I think there is a misunderstanding regarding the way the DISTINCT clause is supported in our MongoSQL. These last three scenarios don't comply with the MongoSQL specification for the DISTINCT clause. The proper syntax is:
SELECT [FLATTEN | FLATTEN_ARRAY | JSON] DISTINCT <field> FROM <collection_name>
i.e. the DISTINCT keyword is a clause of the SELECT statement, not an attribute of a projection field. Also, according to our specification, only one projection field can occur when the DISTINCT keyword is present.
However, there was no error message for the first scenario. I've fixed this for the next Mongo JDBC release.
Another syntax related to the DISTINCT keyword is the following one (supported only for the COUNT() aggregate function):
SELECT COUNT(DISTINCT <field>) FROM <collection_name>
Jonathan, please mention it on the Query Reference wiki page.
I think there is a misunderstanding regarding the way the DISTINCT clause is supported in our MongoSQL. These last three scenarios don't comply with the MongoSQL specification for the DISTINCT clause. The proper syntax is:
SELECT [FLATTEN | FLATTEN_ARRAY | JSON] DISTINCT <field> FROM <collection_name>
i.e. the DISTINCT keyword is a clause of the SELECT statement, not an attribute of a projection field. Also, according to our specification, only one projection field can occur when the DISTINCT keyword is present.
However, there was no error message for the first scenario. I've fixed this for the next Mongo JDBC release.
Another syntax related to the DISTINCT keyword is the following one (supported only for the COUNT() aggregate function):
SELECT COUNT(DISTINCT <field>) FROM <collection_name>
Jonathan, please mention it on the Query Reference wiki page.
and let me know if my addition is okay
and let me know if my addition is okay
Yes, the updated documentation for the DISTINCT clause looks good now. Thank you.
Yes, the updated documentation for the DISTINCT clause looks good now. Thank you.
Verified in Aqua Data Studio Aqua Data Studio 14.0.0-rc-20 Build #: 33993 on Ubuntu 12.04( Mongo DB 2.4.3)
Verified in Aqua Data Studio Aqua Data Studio 14.0.0-rc-20 Build #: 33993 on Ubuntu 12.04( Mongo DB 2.4.3)
Issue #9897 |
Closed |
Fixed |
Resolved |
Completion |
No due date |
Fixed Build ADS 14.0.0-rc-18 (mongo-jdbc 1.3.3) |
No time estimate |
The error message displayed for the first scenario is now also displayed when the
COUNT(DISTINCT <field>)
expression is present.