我使用下面的代码从mongo获取数据。
pipeline = [{'$match': {'createdDateTime': {'$gte': {'$date': f'{yesterday}T00:00:00Z', '$lte': f'{today}T00:00:00Z'}}},
{'$project': { '_class' : {'$ifNull' : ['$_class','']}}}
}
]
df= spark.read.format("com.mongodb.spark.sql.DefaultSource").option("spark.mongodb.input.uri",uri).option("pipeline", pipeline).load()
我不明白这是怎么回事,我得到了下面的例外。
IllegalArgumentException: requirement failed: Invalid Aggregation map Map(uri -> mongodb://xxxx:yyyy@mongo.com:27017/DBReport.Application, pipeline -> [{'$match': {'createdDateTime': {'$gte': {'$date': '2021-08-24T00:00:00Z', '$lte': '2021-08-25T00:00:00Z'}}}}, {'$project': {'_class': {'$ifNull': ['$_class', '']}}
]
请解释
2条答案
按热度按时间u7up0aaq1#
也许你只是漏掉了一些括号。
试试下面的代码
nbysray52#
您可以通过以下方式对MongoDB Spark Connector V10.进行排列