Skip to content

Commit ca905ea

Browse files
Adding JSON view
1 parent 3c2adc3 commit ca905ea

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,31 @@ 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
123+
124+
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:
125+
126+
```sql
127+
CREATE OR ALTER VIEW CovidCases
128+
AS
129+
select
130+
*
131+
from openrowset(
132+
bulk 'latest/ecdc_cases.jsonl',
133+
data_source = 'covid',
134+
format = 'csv',
135+
fieldterminator ='0x0b',
136+
fieldquote = '0x0b'
137+
) with (doc nvarchar(max)) as rows
138+
cross apply openjson (doc)
139+
with ( date_rep datetime2,
140+
cases int,
141+
fatal int '$.deaths',
142+
country varchar(100) '$.countries_and_territories')
143+
```
144+
145+
The `OPENJSON` function parses each line from the JSONL file containing one JSON document per line in textual format.
146+
122147
## Use a view
123148

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

0 commit comments

Comments
 (0)