【发布时间】:2021-12-13 11:49:30
【问题描述】:
我在 Azure Cosmos DB 中有一个容器,该容器在同一个容器中有多种文档类型。因此,根据类型,密钥对会发生变化。我正在尝试使用以下代码从 Synapse 中的此容器中读取数据:
cfg = {
"spark.cosmos.accountEndpoint": Endpoint,
"spark.cosmos.accountKey": accountKey,
"spark.cosmos.database": databaseName,
"spark.cosmos.container": containerName,
}
df = spark.read.format("cosmos.oltp").options(**cfg)\
.option("spark.cosmos.read.inferSchema.enabled","true").load()
但是,我通过此数据框获取的架构属于第一行的类型。如何确保我读取一种特定类型的数据并相应地推断架构?
【问题讨论】:
标签: azure-cosmosdb azure-synapse