属性 引用在 select 列表中无效,因为它未包含在聚合函数或 GROUP BY 子句中
Property reference is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause
Azure Cosmos Document DB 在执行这样的查询时抛出错误 -
SELECT DISTINCT VALUE
{
DocumentName: c.Name,
Count: COUNT(c.id),
Target: c.Target
}
FROM c where c.Target != null
错误-
SC2102: Property reference 'c.Name' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause
SC2102: Property reference 'c.Target' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause
在常规 SQL 中,我会通过添加
来解决这个问题
GROUP BY c.Name, c.Target
在查询末尾,但 Cosmos DB 似乎不支持组子句。
SC1001: Syntax error, incorrect syntax near 'GROUP'.
我想知道是否支持类似 GROUP 的子句。而如果不支持,这个错误是什么意思?
基于 azure cosmos db feedback,group by
目前正在积极开发中,将尽快发货。
目前,您可以参考SO线程 which is very helpful for you. The answer has written a library documentdb-lumenize based on Document Db stored procedure,您可以尝试一下。
如果您确实关心 RU,当然可以衡量存储过程的 RU 消耗。
您可以在 Cosmos DB SDK 中调用 executeStoredProcedure
方法,然后使用 getRequestCharge()
方法。它不会显示在门户中。
如Java代码:
StoredProcedureResponse resourceResponse = documentClient.executeStoredProcedure("dbs/db/colls/item/sprocs/b",requestOptions ,null);
System.out.println(resourceResponse.getRequestCharge());
Azure Cosmos Document DB 在执行这样的查询时抛出错误 -
SELECT DISTINCT VALUE
{
DocumentName: c.Name,
Count: COUNT(c.id),
Target: c.Target
}
FROM c where c.Target != null
错误-
SC2102: Property reference 'c.Name' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause
SC2102: Property reference 'c.Target' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause
在常规 SQL 中,我会通过添加
来解决这个问题GROUP BY c.Name, c.Target
在查询末尾,但 Cosmos DB 似乎不支持组子句。
SC1001: Syntax error, incorrect syntax near 'GROUP'.
我想知道是否支持类似 GROUP 的子句。而如果不支持,这个错误是什么意思?
基于 azure cosmos db feedback,group by
目前正在积极开发中,将尽快发货。
目前,您可以参考SO线程
如果您确实关心 RU,当然可以衡量存储过程的 RU 消耗。
您可以在 Cosmos DB SDK 中调用 executeStoredProcedure
方法,然后使用 getRequestCharge()
方法。它不会显示在门户中。
如Java代码:
StoredProcedureResponse resourceResponse = documentClient.executeStoredProcedure("dbs/db/colls/item/sprocs/b",requestOptions ,null);
System.out.println(resourceResponse.getRequestCharge());