Skip to content

Commit 83f9084

Browse files
Update query-data-storage.md
1 parent a7e964f commit 83f9084

File tree

1 file changed

+4
-75
lines changed

1 file changed

+4
-75
lines changed

articles/synapse-analytics/sql/query-data-storage.md

Lines changed: 4 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ms.reviewer: jrasnick, carlrab
1414
# Overview: Query data in storage
1515

1616
This section contains sample queries you can use to try out the SQL on-demand (preview) resource within Azure Synapse Analytics.
17-
Currently supported files are:
17+
Currently supported file formats are:
1818
- CSV
1919
- Parquet
2020
- JSON
@@ -39,14 +39,7 @@ Additionally, the parameters are as follows:
3939

4040
## First-time setup
4141

42-
Before using the samples included later in this article, you have two steps:
43-
44-
- Create a database for your views (in case you want to use views)
45-
- Create credentials to be used by SQL on-demand to access the files in storage
46-
47-
### Create database
48-
49-
You need a database to create views. You'll use this database for some of the sample queries in this documentation.
42+
Your first step is to **create a database** where you will execute the queries. Then initialize the objects by executing [setup script](https://github.com/Azure-Samples/Synapse/blob/master/SQL/Samples/LdwSample/SampleDB.sql) on that database. This setup script will create the data sources, database scoped credentials, and external file formats that are used to read data in these samples.
5043

5144
> [!NOTE]
5245
> Databases are only used for viewing metadata, not for actual data. Write down the database name that you use, you will need it later on.
@@ -55,53 +48,6 @@ You need a database to create views. You'll use this database for some of the sa
5548
CREATE DATABASE mydbname;
5649
```
5750

58-
### Create credentials
59-
60-
You must create credentials before you can run queries. This credential will be used by SQL on-demand service to access the files in storage.
61-
62-
> [!NOTE]
63-
> In order to successfully run How To's in this section you have to use SAS token.
64-
>
65-
> To start using SAS tokens you have to drop the UserIdentity which is explained in the following [article](develop-storage-files-storage-access-control.md#disable-forcing-azure-ad-pass-through).
66-
>
67-
> SQL on-demand by default always uses AAD pass-through.
68-
69-
For more information on how to manage storage access control, check this [link](develop-storage-files-storage-access-control.md).
70-
71-
To create credentials for CSV, JSON, and Parquet containers, run the code below:
72-
73-
```sql
74-
-- create credentials for CSV container in our demo storage account
75-
IF EXISTS (SELECT * FROM sys.credentials WHERE name = 'https://sqlondemandstorage.blob.core.windows.net/csv')
76-
DROP CREDENTIAL [https://sqlondemandstorage.blob.core.windows.net/csv];
77-
GO
78-
79-
CREATE CREDENTIAL [https://sqlondemandstorage.blob.core.windows.net/csv]
80-
WITH IDENTITY='SHARED ACCESS SIGNATURE',
81-
SECRET = 'sv=2018-03-28&ss=bf&srt=sco&sp=rl&st=2019-10-14T12%3A10%3A25Z&se=2061-12-31T12%3A10%3A00Z&sig=KlSU2ullCscyTS0An0nozEpo4tO5JAgGBvw%2FJX2lguw%3D';
82-
GO
83-
84-
-- create credentials for JSON container in our demo storage account
85-
IF EXISTS (SELECT * FROM sys.credentials WHERE name = 'https://sqlondemandstorage.blob.core.windows.net/json')
86-
DROP CREDENTIAL [https://sqlondemandstorage.blob.core.windows.net/json];
87-
GO
88-
89-
CREATE CREDENTIAL [https://sqlondemandstorage.blob.core.windows.net/json]
90-
WITH IDENTITY='SHARED ACCESS SIGNATURE',
91-
SECRET = 'sv=2018-03-28&ss=bf&srt=sco&sp=rl&st=2019-10-14T12%3A10%3A25Z&se=2061-12-31T12%3A10%3A00Z&sig=KlSU2ullCscyTS0An0nozEpo4tO5JAgGBvw%2FJX2lguw%3D';
92-
GO
93-
94-
-- create credentials for PARQUET container in our demo storage account
95-
IF EXISTS (SELECT * FROM sys.credentials WHERE name = 'https://sqlondemandstorage.blob.core.windows.net/parquet')
96-
DROP CREDENTIAL [https://sqlondemandstorage.blob.core.windows.net/parquet];
97-
GO
98-
99-
CREATE CREDENTIAL [https://sqlondemandstorage.blob.core.windows.net/parquet]
100-
WITH IDENTITY='SHARED ACCESS SIGNATURE',
101-
SECRET = 'sv=2018-03-28&ss=bf&srt=sco&sp=rl&st=2019-10-14T12%3A10%3A25Z&se=2061-12-31T12%3A10%3A00Z&sig=KlSU2ullCscyTS0An0nozEpo4tO5JAgGBvw%2FJX2lguw%3D';
102-
GO
103-
```
104-
10551
## Provided demo data
10652

10753
Demo data contains the following data sets:
@@ -127,24 +73,6 @@ Demo data contains the following data sets:
12773
| /json/ | Parent folder for data in JSON format |
12874
| /json/books/ | JSON files with books data |
12975

130-
## Validation
131-
132-
Execute the following three queries and check if the credentials are created correctly.
133-
134-
> [!NOTE]
135-
> All URIs in the sample queries use a storage account located in the North Europe Azure region. Make sure that you created the appropriate credential. Run the query below and make sure the storage account is listed.
136-
137-
```sql
138-
SELECT name
139-
FROM sys.credentials
140-
WHERE
141-
name IN ( 'https://sqlondemandstorage.blob.core.windows.net/csv',
142-
'https://sqlondemandstorage.blob.core.windows.net/parquet',
143-
'https://sqlondemandstorage.blob.core.windows.net/json');
144-
```
145-
146-
If you can't find the appropriate credential, check [First-time setup](#first-time-setup).
147-
14876
### Sample query
14977

15078
The last step of validation is to execute the following query:
@@ -154,7 +82,8 @@ SELECT
15482
COUNT_BIG(*)
15583
FROM
15684
OPENROWSET(
157-
BULK 'https://sqlondemandstorage.blob.core.windows.net/parquet/taxi/year=2017/month=9/*.parquet',
85+
BULK 'parquet/taxi/year=2017/month=9/*.parquet',
86+
DATA_SOURCE = 'sqlondemanddemo',
15887
FORMAT='PARQUET'
15988
) AS nyc;
16089
```

0 commit comments

Comments
 (0)