I have a container in Azure Cosmos DB that has multiple document types in the same container. So based on the type, the key pairs change. I'm trying to read the data from this container in Synapse using the following code:
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()
However, the schema that I'm getting through this dataframe is of the first row's type. How can I ensure that I read data for one particular type and the schema is inferred accordingly?