Skip to content

Commit ec8ce22

Browse files
authored
Merge pull request #111941 from MightyPen/apr19az6
Apply 'syntaxsql' colorizer, for Synapse Analytics.
2 parents 3b474bc + be06751 commit ec8ce22

File tree

4 files changed

+68
-46
lines changed

4 files changed

+68
-46
lines changed

articles/synapse-analytics/sql-data-warehouse/column-level-security.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ manager: craigg
77
ms.service: synapse-analytics
88
ms.topic: conceptual
99
ms.subservice:
10-
ms.date: 02/05/2020
10+
ms.date: 04/19/2020
1111
ms.author: jrasnick
1212
ms.reviewer: igorstan, carlrab
1313
ms.custom: seo-lt-2019
1414
tags: azure-synapse
1515
---
16-
1716
# Column-level Security
1817

1918
Column-Level Security allows customers to control access to table columns based on the user's execution context or group membership.
@@ -29,7 +28,7 @@ You could implement column-level security with the [GRANT](/sql/t-sql/statements
2928

3029
## Syntax
3130

32-
```sql
31+
```syntaxsql
3332
GRANT <permission> [ ,...n ] ON
3433
[ OBJECT :: ][ schema_name ]. object_name [ ( column [ ,...n ] ) ]
3534
TO <database_principal> [ ,...n ]
@@ -72,8 +71,8 @@ Queries executed as `TestUser` will fail if they include the SSN column:
7271
```sql
7372
SELECT * FROM Membership;
7473

75-
Msg 230, Level 14, State 1, Line 12
76-
The SELECT permission was denied on the column 'SSN' of the object 'Membership', database 'CLS_TestDW', schema 'dbo'.
74+
-- Msg 230, Level 14, State 1, Line 12
75+
-- The SELECT permission was denied on the column 'SSN' of the object 'Membership', database 'CLS_TestDW', schema 'dbo'.
7776
```
7877

7978
## Use Cases

articles/synapse-analytics/sql/develop-openrowset.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ OPENROWSET is currently not supported in SQL pool.
2121

2222
## Syntax
2323

24-
```
24+
```syntaxsql
2525
--OPENROWSET syntax for reading Parquet files
2626
OPENROWSET
2727
( { BULK 'unstructured_data_path' ,
@@ -55,38 +55,39 @@ You have two choices for input files that contain the target data for querying.
5555

5656
- 'PARQUET' - Binary file in Parquet format
5757

58-
'unstructured_data_path'
58+
**'unstructured_data_path'**
5959

60-
The unstructured_data_path that establishes
61-
a path to the data is structured as follows:
62-
'<prefix>://<storage_account_path>/<storage_path>'
60+
The unstructured_data_path that establishes a path to the data is structured as follows:
61+
'\<prefix>://\<storage_account_path>/\<storage_path>'
6362

6463

6564
Below you'll find the relevant storage account paths that will link to your particular external data source.
6665

67-
| External Data Source | Prefix | Storage account path |
68-
| -------------------------- | ------ | --------------------------------------------------- |
69-
| Azure Blob Storage | https | <storage_account>.blob.core.windows.net |
70-
| Azure Data Lake Store Gen1 | https | <storage_account>.azuredatalakestore.net/webhdfs/v1 |
71-
| Azure Data Lake Store Gen2 | https | <storage_account>.dfs.core.windows.net |
66+
| External Data Source | Prefix | Storage account path |
67+
| -------------------------- | ------ | ---------------------------------------------------- |
68+
| Azure Blob Storage | https | \<storage_account>.blob.core.windows.net |
69+
| Azure Data Lake Store Gen1 | https | \<storage_account>.azuredatalakestore.net/webhdfs/v1 |
70+
| Azure Data Lake Store Gen2 | https | \<storage_account>.dfs.core.windows.net |
71+
||||
7272

73-
'<storage_path>'
73+
'\<storage_path>'
7474

7575
Specifies a path within your storage that points to the folder or file you want to read. If the path points to a container or folder, all files will be read from that particular container or folder. Files in subfolders won't be included.
7676

7777
You can use wildcards to target multiple files or folders. Usage of multiple nonconsecutive wildcards is allowed.
78-
Below is an example that reads all *csv* files starting with *population* from all folders starting with */csv/population*: 'https://sqlondemandstorage.blob.core.windows.net/csv/population*/population*.csv'
78+
Below is an example that reads all *csv* files starting with *population* from all folders starting with */csv/population*:
79+
`https://sqlondemandstorage.blob.core.windows.net/csv/population*/population*.csv`
7980

8081
If you specify the unstructured_data_path to be a folder, a SQL on-demand query will retrieve files from that folder.
8182

8283
> [!NOTE]
8384
> Unlike Hadoop and PolyBase, SQL on-demand doesn't return subfolders. Also, unlike Hadoop and PloyBase, SQL on-demand does return files for which the file name begins with an underline (_) or a period (.).
8485
85-
In the example below, if the unstructured_data_path='https://mystorageaccount.dfs.core.windows.net/webdata/', a SQL on-demand query will return rows from mydata.txt and _hidden.txt. It won't return mydata2.txt and mydata3.txt because they are located in a subfolder.
86+
In the example below, if the unstructured_data_path=`https://mystorageaccount.dfs.core.windows.net/webdata/`, a SQL on-demand query will return rows from mydata.txt and _hidden.txt. It won't return mydata2.txt and mydata3.txt because they are located in a subfolder.
8687

8788
![Recursive data for external tables](./media/develop-openrowset/folder-traversal.png)
8889

89-
[WITH ( {'column_name' 'column_type' [ 'column_ordinal'] }) ]
90+
`[WITH ( {'column_name' 'column_type' [ 'column_ordinal'] }) ]`
9091

9192
The WITH clause allows you to specify columns that you want to read from files.
9293

@@ -110,7 +111,8 @@ WITH (
110111
--[population] bigint
111112
)
112113
```
113-
<bulk_options>
114+
115+
**\<bulk_options>**
114116

115117
FIELDTERMINATOR ='field_terminator'
116118

articles/synapse-analytics/sql/develop-storage-files-overview.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ author: azaricstefan
66
ms.service: synapse-analytics
77
ms.topic: overview
88
ms.subservice:
9-
ms.date: 04/15/2020
9+
ms.date: 04/19/2020
1010
ms.author: v-stazar
1111
ms.reviewer: jrasnick, carlrab
1212
---
13-
1413
# Query storage files using SQL on-demand (preview) resources within Synapse SQL
1514

1615
SQL on-demand (preview) enables you to query data in your data lake. It offers a T-SQL query surface area that accommodates semi-structured and unstructured data queries.
@@ -57,7 +56,7 @@ Refer to [Query folders and multiple files](query-folders-multiple-csv-files.md)
5756

5857
To query Parquet source data, use FORMAT = 'PARQUET'
5958

60-
```sql
59+
```syntaxsql
6160
OPENROWSET
6261
(
6362
{ BULK 'data_file' ,
@@ -119,7 +118,6 @@ By omitting the WITH clause from OPENROWSET statement, you can instruct the serv
119118
```sql
120119
OPENROWSET(
121120
BULK N'path_to_file(s)', FORMAT='PARQUET');
122-
123121
```
124122

125123
### Filename function
@@ -161,7 +159,7 @@ To access nested elements from a nested column, such as Struct, use "dot notatio
161159

162160
The syntax fragment example is as follows:
163161

164-
```sql
162+
```syntaxsql
165163
OPENROWSET
166164
( BULK 'unstructured_data_path' ,
167165
FORMAT = 'PARQUET' )
@@ -195,7 +193,7 @@ To access non-scalar elements from a repeated column, use the [JSON_QUERY](/sql/
195193

196194
See syntax fragment below:
197195

198-
```sql
196+
```syntaxsql
199197
SELECT
200198
{ JSON_VALUE (column_name, path_to_sub_element), }
201199
{ JSON_QUERY (column_name [ , path_to_sub_element ]), )

articles/synapse-analytics/sql/develop-tables-statistics.md

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ manager: craigg
77
ms.service: synapse-analytics
88
ms.topic: conceptual
99
ms.subservice:
10-
ms.date: 04/15/2020
10+
ms.date: 04/19/2020
1111
ms.author: fipopovi
1212
ms.reviewer: jrasnick
1313
ms.custom:
1414
---
15-
1615
# Statistics in Synapse SQL
1716

1817
Provided in this article are recommendations and examples for creating and updating query-optimization statistics using the Synapse SQL resources: SQL pool and SQL on-demand (preview).
@@ -158,35 +157,43 @@ To create statistics on a column, provide a name for the statistics object and t
158157
This syntax uses all of the default options. By default, SQL pool samples **20 percent** of the table when it creates statistics.
159158

160159
```sql
161-
CREATE STATISTICS [statistics_name] ON [schema_name].[table_name]([column_name]);
160+
CREATE STATISTICS [statistics_name]
161+
ON [schema_name].[table_name]([column_name]);
162162
```
163163

164164
For example:
165165

166166
```sql
167-
CREATE STATISTICS col1_stats ON dbo.table1 (col1);
167+
CREATE STATISTICS col1_stats
168+
ON dbo.table1 (col1);
168169
```
169170

170171
#### Create single-column statistics by examining every row
171172

172173
The default sampling rate of 20 percent is sufficient for most situations. However, you can adjust the sampling rate. To sample the full table, use this syntax:
173174

174175
```sql
175-
CREATE STATISTICS [statistics_name] ON [schema_name].[table_name]([column_name]) WITH FULLSCAN;
176+
CREATE STATISTICS [statistics_name]
177+
ON [schema_name].[table_name]([column_name])
178+
WITH FULLSCAN;
176179
```
177180

178181
For example:
179182

180183
```sql
181-
CREATE STATISTICS col1_stats ON dbo.table1 (col1) WITH FULLSCAN;
184+
CREATE STATISTICS col1_stats
185+
ON dbo.table1 (col1)
186+
WITH FULLSCAN;
182187
```
183188

184189
#### Create single-column statistics by specifying the sample size
185190

186191
Another option you have is to specify the sample size as a percent:
187192

188193
```sql
189-
CREATE STATISTICS col1_stats ON dbo.table1 (col1) WITH SAMPLE = 50 PERCENT;
194+
CREATE STATISTICS col1_stats
195+
ON dbo.table1 (col1)
196+
WITH SAMPLE = 50 PERCENT;
190197
```
191198

192199
#### Create single-column statistics on only some of the rows
@@ -198,7 +205,9 @@ For example, you can use filtered statistics when you plan to query a specific p
198205
This example creates statistics on a range of values. The values can easily be defined to match the range of values in a partition.
199206

200207
```sql
201-
CREATE STATISTICS stats_col1 ON table1(col1) WHERE col1 > '2000101' AND col1 < '20001231';
208+
CREATE STATISTICS stats_col1
209+
ON table1(col1)
210+
WHERE col1 > '2000101' AND col1 < '20001231';
202211
```
203212

204213
> [!NOTE]
@@ -209,7 +218,10 @@ CREATE STATISTICS stats_col1 ON table1(col1) WHERE col1 > '2000101' AND col1 < '
209218
You can also combine the options together. The following example creates a filtered statistics object with a custom sample size:
210219

211220
```sql
212-
CREATE STATISTICS stats_col1 ON table1 (col1) WHERE col1 > '2000101' AND col1 < '20001231' WITH SAMPLE = 50 PERCENT;
221+
CREATE STATISTICS stats_col1
222+
ON table1 (col1)
223+
WHERE col1 > '2000101' AND col1 < '20001231'
224+
WITH SAMPLE = 50 PERCENT;
213225
```
214226

215227
For the full reference, see [CREATE STATISTICS](/sql/t-sql/statements/create-statistics-transact-sql?toc=/azure/synapse-analytics/toc.json&bc=/azure/synapse-analytics/breadcrumb/toc.json&view=azure-sqldw-latest).
@@ -224,7 +236,10 @@ To create a multi-column statistics object, use the previous examples, but speci
224236
In this example, the histogram is on *product\_category*. Cross-column statistics are calculated on *product\_category* and *product\_sub_category*:
225237

226238
```sql
227-
CREATE STATISTICS stats_2cols ON table1 (product_category, product_sub_category) WHERE product_category > '2000101' AND product_category < '20001231' WITH SAMPLE = 50 PERCENT;
239+
CREATE STATISTICS stats_2cols
240+
ON table1 (product_category, product_sub_category)
241+
WHERE product_category > '2000101' AND product_category < '20001231'
242+
WITH SAMPLE = 50 PERCENT;
228243
```
229244

230245
Because a correlation exists between *product\_category* and *product\_sub\_category*, a multi-column statistics object can be useful if these columns are accessed at the same time.
@@ -258,7 +273,7 @@ The following example will help you get started with your database design. Feel
258273

259274
```sql
260275
CREATE PROCEDURE [dbo].[prc_sqldw_create_stats]
261-
( @create_type tinyint -- 1 default 2 Fullscan 3 Sample
276+
( @create_type tinyint -- 1 default, 2 Fullscan, 3 Sample
262277
, @sample_pct tinyint
263278
)
264279
AS
@@ -465,8 +480,8 @@ JOIN sys.stats_columns AS sc ON st.[stats_id] = sc.[stats_id]
465480
JOIN sys.columns AS co ON sc.[column_id] = co.[column_id]
466481
AND sc.[object_id] = co.[object_id]
467482
JOIN sys.types AS ty ON co.[user_type_id] = ty.[user_type_id]
468-
JOIN sys.tables AS tb ON co.[object_id] = tb.[object_id]
469-
JOIN sys.schemas AS sm ON tb.[schema_id] = sm.[schema_id]
483+
JOIN sys.tables AS tb ON co.[object_id] = tb.[object_id]
484+
JOIN sys.schemas AS sm ON tb.[schema_id] = sm.[schema_id]
470485
WHERE 1=1
471486
AND st.[user_created] = 1
472487
;
@@ -501,18 +516,20 @@ DBCC SHOW_STATISTICS (dbo.table1, stats_col1);
501516
If you're only interested in viewing specific parts, use the `WITH` clause and specify which parts you want to see:
502517

503518
```sql
504-
DBCC SHOW_STATISTICS([<schema_name>.<table_name>],<stats_name>) WITH stat_header, histogram, density_vector
519+
DBCC SHOW_STATISTICS([<schema_name>.<table_name>],<stats_name>)
520+
WITH stat_header, histogram, density_vector
505521
```
506522

507523
For example:
508524

509525
```sql
510-
DBCC SHOW_STATISTICS (dbo.table1, stats_col1) WITH histogram, density_vector
526+
DBCC SHOW_STATISTICS (dbo.table1, stats_col1)
527+
WITH histogram, density_vector
511528
```
512529

513530
### DBCC SHOW_STATISTICS() differences
514531

515-
DBCC SHOW_STATISTICS() is more strictly implemented in SQL pool compared to SQL Server:
532+
`DBCC SHOW_STATISTICS()` is more strictly implemented in SQL pool compared to SQL Server:
516533

517534
- Undocumented features aren't supported.
518535
- Can't use Stats_stream.
@@ -599,7 +616,7 @@ Arguments:
599616
[ @stmt = ] N'statement_text' -
600617
Specifies a Transact-SQL statement that will return column values to be used for statistics. You can use TABLESAMPLE to specify samples of data to be used. If TABLESAMPLE isn't specified, FULLSCAN will be used.
601618

602-
```sql
619+
```syntaxsql
603620
<tablesample_clause> ::= TABLESAMPLE ( sample_number PERCENT )
604621
```
605622

@@ -747,14 +764,18 @@ SAMPLE cannot be used with the FULLSCAN option.
747764
#### Create single-column statistics by examining every row
748765

749766
```sql
750-
CREATE STATISTICS sState on census_external_table (STATENAME) WITH FULLSCAN, NORECOMPUTE
767+
CREATE STATISTICS sState
768+
on census_external_table (STATENAME)
769+
WITH FULLSCAN, NORECOMPUTE
751770
```
752771

753772
#### Create single-column statistics by specifying the sample size
754773

755774
```sql
756775
-- following sample creates statistics with sampling 20%
757-
CREATE STATISTICS sState on census_external_table (STATENAME) WITH SAMPLE 5 percent, NORECOMPUTE
776+
CREATE STATISTICS sState
777+
on census_external_table (STATENAME)
778+
WITH SAMPLE 5 percent, NORECOMPUTE
758779
```
759780

760781
### Examples: Update statistics
@@ -768,7 +789,9 @@ DROP STATISTICS census_external_table.sState
768789
And create statistics:
769790

770791
```sql
771-
CREATE STATISTICS sState on census_external_table (STATENAME) WITH FULLSCAN, NORECOMPUTE
792+
CREATE STATISTICS sState
793+
on census_external_table (STATENAME)
794+
WITH FULLSCAN, NORECOMPUTE
772795
```
773796

774797
## Next steps

0 commit comments

Comments
 (0)