Skip to content

Commit ae08937

Browse files
authored
Merge pull request #171490 from jovanpop-msft/patch-220
Added CosmosDB view
2 parents 272ab20 + 825783d commit ae08937

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

articles/synapse-analytics/sql/create-use-views.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ The folder name in the `OPENROWSET` function (`yellow` in this example) that is
119119
120120
Delta Lake is in public preview and there are some known issues and limitations. Review the known issues on [Synapse serverless SQL pool self-help page](resources-self-help-sql-on-demand.md#delta-lake).
121121

122-
### JSON views
122+
## JSON views
123123

124124
The views are the good choice if you need to do some additional processing on top of the result set that is fetched from the files. One example might be parsing JSON files where we need to apply the JSON functions to extract the values from the JSON documents:
125125

@@ -144,6 +144,26 @@ from openrowset(
144144

145145
The `OPENJSON` function parses each line from the JSONL file containing one JSON document per line in textual format.
146146

147+
## CosmosDB view
148+
149+
The views can be created on top of the Azure CosmosDB containers if the CosmosDB analytical storage is enabled on the container. CosmosDB account name, database name, and container name should be added as a part of the view, and the read-only access key should be placed in the database scoped credential that the view references.
150+
151+
```sql
152+
CREATE DATABASE SCOPED CREDENTIAL MyCosmosDbAccountCredential
153+
WITH IDENTITY = 'SHARED ACCESS SIGNATURE', SECRET = 's5zarR2pT0JWH9k8roipnWxUYBegOuFGjJpSjGlR36y86cW0GQ6RaaG8kGjsRAQoWMw1QKTkkX8HQtFpJjC8Hg==';
154+
GO
155+
CREATE OR ALTER VIEW Ecdc
156+
AS SELECT *
157+
FROM OPENROWSET(
158+
PROVIDER = 'CosmosDB',
159+
CONNECTION = 'Account=synapselink-cosmosdb-sqlsample;Database=covid',
160+
OBJECT = 'Ecdc',
161+
CREDENTIAL = 'MyCosmosDbAccountCredential'
162+
) with ( date_rep varchar(20), cases bigint, geo_id varchar(6) ) as rows
163+
```
164+
165+
Find more details about [querying CosmosDB containers using Synapse Link here](query-cosmos-db-analytical-store.md).
166+
147167
## Use a view
148168

149169
You can use views in your queries the same way you use views in SQL Server queries.

0 commit comments

Comments
 (0)