问题
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