当我在门户中运行这样的查询时,它运行得很好。但是,当我从python SDK运行它时,出现“跨分区查询仅支持'VALUE'的聚合。”。我想在所有分区上运行它。关于如何使其从SDK运行的任何建议?
谢谢, 彼得
选择 c.data.video.id, COUNT(1)作为nTrace, MAX(c.data.time)作为lastReport 来自c WHERE c.data.time>“ 2020-06-02T17:40:25.593141 + 00:00” GROUP BY c.data.video.id
答案 0 :(得分:0)
根据我的测试,python sdk不支持group by
。
下面是我的测试代码:
query = "SELECT c.id FROM c group by c.id"
items = list(container.query_items(
query=query,
enable_cross_partition_query=True
))
这是错误:
azure.cosmos.exceptions.CosmosHttpResponseError: (BadRequest) Gateway Failed to Retrieve Query Plan: Query contains 1 or more unsupported features. Upgrade your SDK to a version that does support the requested features:
Query contained GroupBy, which the calling client does not support.
请参阅此document ,. net sdk和js sdk支持group by
。
因此,您可以使用.net sdk和js sdk来做到这一点。
顺便说一句,我搜索了python sdk release history,但没有提到支持group by
。
希望这可以为您提供帮助。