我想使用DocumentDB,但PySpark没有连接器。看起来像DocumentDB也支持MongoDB Protocol as mentioned here,这意味着所有现有的MongoDB驱动程序应该工作。由于有PySpark connector for MongoDB,我想尝试一下。带有MongoDB协议的Azure DocumentDB Spark集成
df = spark.read.format("com.mongodb.spark.sql.DefaultSource").load()
这会引发错误。
com.mongodb.MongoCommandException: Command failed with error 115: ''$sample' is not supported' on server example.documents.azure.com:10250. The full response is { "_t" : "OKMongoResponse", "ok" : 0, "code" : 115, "errmsg" : "'$sample' is not supported", "$err" : "'$sample' is not supported" }
它看起来像DocumentDB MongoDB的API不支持MongoDB的所有功能,但我找不到任何文档。还是我错过了别的?
感谢您的回答。这就是我的想法。 – chhantyal
与'PyDocumentDB'一起使用是不够的。因为根据文档中给出的示例,在创建DataFrame之前,您必须在内存中显式转换为Python数据类型,但它不适用于大量数据。 – chhantyal
@chhantyal对于大量数据,解决方法是按切片查询多个数据帧并使用['union'](http://spark.apache.org/docs/latest/api/python/pyspark.sql.html #pyspark.sql.DataFrame.union)方法来生成包含所有小尺寸数据框的新数据框。 –