Skip to content

Commit 8d8aeac

Browse files
author
Matt Usher
authored
Merge pull request #39 from Azure-Samples/sqlextension
Removing the kurtosis function, adding the dbc.tables view
2 parents fd8b347 + 015305a commit 8d8aeac

File tree

7 files changed

+82
-22
lines changed

7 files changed

+82
-22
lines changed

SQL/Extension/deploy.bat

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ sqlcmd -S %_server% -d %_database% -U %_username% -P %_password% -I -i .\functio
5151
sqlcmd -S %_server% -d %_database% -U %_username% -P %_password% -I -i .\functions\microsoft.dayoccurrence_of_month.sql
5252
sqlcmd -S %_server% -d %_database% -U %_username% -P %_password% -I -i .\functions\microsoft.initcap.sql
5353
sqlcmd -S %_server% -d %_database% -U %_username% -P %_password% -I -i .\functions\microsoft.instr.sql
54-
sqlcmd -S %_server% -d %_database% -U %_username% -P %_password% -I -i .\functions\microsoft.kurtosis.sql
5554
sqlcmd -S %_server% -d %_database% -U %_username% -P %_password% -I -i .\functions\microsoft.lpad.sql
5655
sqlcmd -S %_server% -d %_database% -U %_username% -P %_password% -I -i .\functions\microsoft.months_between.sql
5756
sqlcmd -S %_server% -d %_database% -U %_username% -P %_password% -I -i .\functions\microsoft.next_day.sql

SQL/Extension/functions/Readme.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ The `microsoft.initcap` script installs a function that emulates the `INITCAP(ex
1515
## microsoft.instr
1616
The `microsoft.instr` script installs a function that emulates the `INSTR(expression, substring, position, occurrence)` function found in Oracle and Teradata.
1717

18-
## microsoft.kurtosis
19-
The `microsoft.kurtosis` script installs a function that emulates the `KURTOSIS(expression)` ANSI function.
20-
2118
## microsoft.lpad
2219
The `microsoft.lpad` script installs a function that emulates the `LPAD(expression, length [, fill])` TERADATA function.
2320

SQL/Extension/functions/microsoft.kurtosis.sql

Lines changed: 0 additions & 18 deletions
This file was deleted.

SQL/Extension/schemas/Readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Schemas
22

3+
## dbc
4+
The `dbc` script creates the `dbc` schema in the Azure Synapse SQL database.
5+
36
## microsoft
47
The `microsoft` script creates the `microsoft` schema in the Azure Synapse SQL database.

SQL/Extension/schemas/dbc.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
IF (NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'dbc'))
2+
BEGIN
3+
EXEC ('CREATE SCHEMA [dbc]');
4+
END

SQL/Extension/views/Readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Views
22

3+
## dbc.tables
4+
The `dbc.tables` script installs a view that mimics the `DBC.TABLES` view found in Teradata.
5+
Note: See the [`DBC.TABLES`](https://docs.teradata.com/reader/b7YPw3QMO~fsDCrY39kyiQ/NWKolQulMcPxjjpRzelZxA)
6+
37
## microsoft.dw_active_queries
48
The `microsoft.dw_active_queries` script installs a view that shows the active queries from the `sys.dm_pdw_exec_requests` view.
59

SQL/Extension/views/dbc.tables.sql

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
DROP VIEW IF EXISTS [dbc].[tables];
2+
GO
3+
4+
CREATE VIEW [dbc].[tables] AS
5+
SELECT
6+
[DatabaseName] = SCHEMA_NAME(o.schema_id)
7+
, [TableName] = o.[name]
8+
, [Version] = 1
9+
, [TableKind] = CASE o.type
10+
WHEN '' THEN 'A' -- Aggregate Function
11+
WHEN '' THEN 'B' -- Combined aggregate and ordered analytical function
12+
WHEN '' THEN 'C' -- Table operator parser contract function
13+
WHEN '' THEN 'D' -- JAR
14+
WHEN '' THEN 'E' -- External stored procedure
15+
WHEN 'FN' THEN 'F' -- Standard Function
16+
WHEN '' THEN 'G' -- Trigger
17+
WHEN '' THEN 'H' -- Instance or constructor method
18+
WHEN '' THEN 'I' -- Join Index
19+
WHEN '' THEN 'J' -- Journal
20+
WHEN '' THEN 'K' -- Foreign server object.
21+
-- Note: K is supported on the Teradata-to-Hadoop connector only.
22+
WHEN '' THEN 'L' -- User-defined table operator
23+
WHEN '' THEN 'M' -- Macro
24+
WHEN '' THEN 'N' -- Hash Index
25+
WHEN '' THEN 'O' -- Table with no primary index and no paritioning
26+
WHEN 'P' THEN 'P' -- Stored procedure
27+
WHEN '' THEN 'Q' -- Queue table
28+
WHEN '' THEN 'R' -- Table function
29+
WHEN '' THEN 'S' -- Ordered analytical function
30+
WHEN 'U' THEN 'T' -- Table with a primary index or primary AMP index, partitioning, or both. Or a partitioned table with NoPI
31+
WHEN '' THEN 'U' -- User-defined type
32+
WHEN 'V' THEN 'V' -- View
33+
WHEN '' THEN 'X' -- Authorization
34+
WHEN '' THEN 'Y' -- GLOP set
35+
WHEN '' THEN 'Z' -- UIF
36+
ELSE
37+
o.type
38+
END
39+
, [ProtectionType] = 'N'
40+
, [JournalFlag] = 'N'
41+
, [CreatorName] = COALESCE(p.name, p.name, 'dbo')
42+
, [RequestText] = NULL --= OBJECT_DEFINITION(OBJECT_ID(N'Purchasing.vVendor'))
43+
, [CommentString] = NULL
44+
, [ParentCount] = 0
45+
, [ChildCount] = 0
46+
, [NamedTblCheckCount] = 0
47+
, [UnnamedTblCheckExist] = 'N'
48+
, [PrimaryKeyIndexId] = NULL
49+
, [RepStatus] = NULL
50+
, [CreateTimeStamp] = o.create_date
51+
, [LastAlterName] = 'dbo'
52+
, [LastAlterTimestamp] = o.modify_date
53+
, [RequestTxtOverflow] = NULL
54+
, [AccessCount] = NULL
55+
, [LastAccessTimeStamp] = NULL
56+
, [UtilVersion] = NULL
57+
, [QueueFlag] = 'N'
58+
, [CommitOpt] = 'N'
59+
, [TransLog] = 'N'
60+
, [CheckOpt] = 'Y'
61+
, [TemporalProperty] = 'N' -- OR NULL
62+
, [ResolvedCurrentDate] = NULL
63+
, [ResolvedCurrentTimestamp] = NULL
64+
, [SystemDefinedJI] = 'N' -- OR NULL
65+
, [VTQualifier] = NULL
66+
, [TTQualifier] = NULL
67+
, o.*
68+
FROM
69+
sys.objects o
70+
LEFT JOIN sys.server_principals p ON p.principal_id = o.principal_id ;
71+
GO

0 commit comments

Comments
 (0)