Alternative to group by for cosmos db

偶尔善良 提交于 2019-12-18 08:13:30

问题


Given that cosmos db does not support group by, what is a good alternative to achieve similar functionality:

Select sum(*) , groupterm from tble group by groupterm

Can I efficiently achieve this in a cosmos stored procedure?


回答1:


Group by is now supported in Cosmos db SQL API. You will be needing SDK version 3.3 or higher

Azure Cosmos DB currently supports GROUP BY in .NET SDK 3.3 or later. Support for other language SDK's and the Azure Portal is not currently available but is planned.

https://docs.microsoft.com/en-gb/azure/cosmos-db/sql-query-group-by




回答2:


As Cosmos_DB states as follows:

Aggregation capability in SQL limited to COUNT, SUM, MIN, MAX, AVG functions. No support for GROUP BY or other aggregation functionality found in database systems. However, stored procedures can be used to implement in-the-database aggregation capability.

Can I efficiently achieve this in a cosmos stored procedure?

For .NET and Node.js

Larry Maccherone has provided a great package documentdb-lumenize which supports Aggregations (Group-by, Pivot-table, and N-dimensional Cube) and Time Series Transformations as Stored Procedures in DocumentDB.

Additionally, for Python and Scala, you could refer to azure-cosmosdb-spark.




回答3:


Finally, Azure Cosmos DB currently supports GROUP BY in .NET SDK 3.3 or later. Support for other language SDK's and the Azure Portal is not currently available but is planned.

<group_by_clause> ::= GROUP BY <scalar_expression_list>

<scalar_expression_list> ::=
          <scalar_expression>
        | <scalar_expression_list>, <scalar_expression>



来源:https://stackoverflow.com/questions/45270125/alternative-to-group-by-for-cosmos-db

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!