Cosmos DB + pyDocumentDB + Databricks

一曲冷凌霜 提交于 2019-12-11 07:37:15

问题


I've got a strange behaviour with pyDocumentDB and Databricks with Cosmos DB . I'm trying to query a collection, connection goes well, but I'm having a little troubles fetching results. If I query in a "general" way I obtain results...

But when I try to fetch, for example, the 'source' field inside the 'tweet' I obtain only an empty result

I queried for collection 'structure' and check the path to the 'source' field. The field exists

I've check all possible path combinations in the SELECT sentence to recover the 'source' field. None returns data. Cosmos DB was created with MongoDB API interface selected. Could that selection being interfering with the SQL sentences?.

Thanks.


回答1:


It is because of Mongo API. You can see the results that are returned is using the $t/$v format. That is what the Mongo API stores into Cosmos DB to keep all the Mongo type information it needs.

Try:

SELECT TOP 10 twttr["$v"].tweet["$v"].source FROM twttr

(Note that $v is not valid without the ["$v"] because $ is a special character in the SQL language)



来源:https://stackoverflow.com/questions/54825691/cosmos-db-pydocumentdb-databricks

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