python-3.x - 错误:写入非空集合
问题描述
我在将 json 写入我的 Cosmos DB 时遇到了问题。我可以在编写相同的数据时读取数据并遇到问题
应用了以下版本的 Cosmos db 连接器 https://docs.azuredatabricks.net/spark/latest/data-sources/azure/cosmosdb-connector.html 并尝试了不同的版本。这个问题仍然存在。
RawFilePath="/mnt/ADLS/Users/test/CosmosDB/testfile.json"
DFRead=spark.read.json(RawFilePath)
DFNew = DFRead.selectExpr("activity", "partition AS xfactor","response", "source", "type")
writeConfig = {
"Endpoint" : "{End Point}",
"Masterkey" : "{MasterKey}",
"Database" : "{DB Name}",
"Collection" : "{Connection name}",
"Upsert" : "true"
}
DFNew.write.format("com.microsoft.azure.cosmosdb.spark").options(**writeConfig).save()
收到以下错误。
Error : java.lang.UnsupportedOperationException: Writing in a non-empty collection.
期望将 json 写入 cosmos DB 集合。但是,无法解决 Databricks 中的非空集合错误。非常感谢您的帮助。
谢谢你..
解决方案
通过指定模式尝试
DFNew.write.format("com.microsoft.azure.cosmosdb.spark").mode("append").options(**writeConfig).save()
推荐阅读
- java - Java 服务 SPI 和内存泄漏
- javascript - Vuex:函数声明和函数名称作为变异键的区别
- java - 如何设置更改的远程文本文件的正确读取点
- python - Python 上的无效语法:“def 方法(self,(x,y)):”
- c++ - 给定的二叉树是有效的 BST 吗?
- java - 如何使用 Lambda 在 S3 存储桶内触发应用程序?
- python - 如何从字典元素中打印特定字符串?
- java - 如何将表单字段值插入数据库
- autodesk-forge - autodesk-forge Photoscene 进度 API - Photoscene 永远不会进步
- java - 在java中将元素添加到两个不同的数组