Skip to content

Commit 9027f59

Browse files
authored
Update analytical-store-introduction.md
1 parent ee94601 commit 9027f59

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

articles/cosmos-db/analytical-store-introduction.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,24 +328,28 @@ Here's a map of all the property data types and their suffix representations in
328328
the MongoDB `_id` field is fundamental to every collection in MongoDB and originally has a hexadecimal representation. As you can see in the table above, `Full Fidelity Schema` will preserve its characteristics, creating a challenge for its vizualiation in Azure Synapse Analytics. For correct visualization, you must convert the `_id` datatype as below:
329329

330330
###### Spark
331-
```scala
331+
332+
```Python
332333
import org.apache.spark.sql.types._
333334
val simpleSchema = StructType(Array(
334335
    StructField("_id", StructType(Array(StructField("objectId",BinaryType,true)) ),true),
335336
    StructField("id", StringType, true)
336337
  ))
337338

338-
var df = spark.read.format("cosmos.olap").option("spark.synapse.linkedService""CosmosDbMongoDbApi2").option("spark.cosmos.container""HTAP").schema(simpleSchema).load()
339+
df = spark.read.format("cosmos.olap")\
340+
.option("spark.synapse.linkedService", "<enter linked service name>")\
341+
.option("spark.cosmos.container", "<enter container name>")\
342+
.schema(simpleSchema)
343+
.load()
339344

340345
df.select("id""_id.objectId").show()
341-
![image](https://user-images.githubusercontent.com/11827523/185008672-e6a98513-2a1d-410b-aeb5-de67ec4e984f.png)
342346
```
343347
###### SQL
344348

345349
```SQL
346350
SELECT TOP 100 id=CAST(_id as VARBINARY(1000))
347351
FROM OPENROWSET('CosmosDB',
348-
                'Account=your-account;Database=your-database;Key=your-key',
352+
                'Your-account;Database=your-database;Key=your-key',
349353
                HTAP) WITH (_id VARCHAR(1000)) as HTAP
350354
```
351355

0 commit comments

Comments
 (0)