我正在尝试使用pyspark中的databricks脚本在mongoDB集合中获取文档。我试图每天获取数据。脚本有几天很好,但是有时会在有一天的错误之后引发。
com.mongodb.MongoInternalException: The reply message length 14484499 is less than the maximum message length 4194304.
不确定此错误是什么以及如何解决此问题。任何帮助都将不胜感激。
这是我正在运行的示例代码:
pipeline = [{'$match':{'$and':[{'UpdatedTimestamp':{'$gte': 1555891200000}},
{'UpdatedTimestamp':{'$lt': 1555977600000}}]}}]
READ_MSG = spark.read.format("com.mongodb.spark.sql.DefaultSource")
.option("uri",connectionstring)
.option("pipeline",pipeline)
.load()
DateTime以时期格式提供。
它比答案更重要(我没有足够的声誉发表评论(。
我也有同样的问题。经过一番研究,我发现正是我的嵌套字段"调查"与1个以上的层次相比,正在创建问题,因为我能够通过选择除此字段以外的所有其他字段来阅读DB:
root
|-- _id: string (nullable = true)
|-- _t: array (nullable = true)
| |-- element: string (containsNull = true)
|-- address: struct (nullable = true)
| |-- streetAddress1: string (nullable = true)
|-- survey: array (nullable = true)
| |-- element: struct (containsNull = true)
| | |-- SurveyQuestionId: string (nullable = true)
| | |-- updated: array (nullable = true)
| | | |-- element: long (containsNull = true)
| | |-- value: string (nullable = true)
是否有人靠近解决方法,似乎是MongoDB Spark Connector的错误?
在mongo db连接字符串中添加appName后,问题似乎已经解决。我现在没有遇到此错误。