从Databricks批量写入Cosmos DB

时间:2020-02-17 21:13:04

标签: pyspark azure-cosmosdb azure-databricks

有人可以让我知道从Databrick写入Cosmos DB时获得的星号**吗?

# Write configuration
writeConfig = {
    "Endpoint": "https://doctorwho.documents.azure.com:443/",
    "Masterkey": "YOUR-KEY-HERE",
    "Database": "DepartureDelays",
    "Collection": "flights_fromsea",
    "Upsert": "true"
}

# Write to Cosmos DB from the flights DataFrame
flights.write.format("com.microsoft.azure.cosmosdb.spark").options(
    **writeConfig).save()

谢谢

1 个答案:

答案 0 :(得分:2)

这仅仅是为了让您直接使用列表,元组或字典传递多个参数。

所以,不是您说的那样:

flights.write.format("com.microsoft.azure.cosmosdb.spark")\
             .option("Endpoint", "https://doctorwho.documents.azure.com:443/")\
             .option("Upsert", "true")\
             .option("Masterkey", "YOUR-KEY-HERE")\
             ...etc 

您只需将所有参数放在字典中,然后像以下一样传递

flights.write.format("com.microsoft.azure.cosmosdb.spark").options(
    **yourdict).save()