This repository was archived by the owner on Aug 23, 2025. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathcustom-sql-examples.graphql
More file actions
124 lines (107 loc) · 3.04 KB
/
Copy pathcustom-sql-examples.graphql
File metadata and controls
124 lines (107 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#####
## CustomSQL Samples - includes various Metadata API queries for understanding how CustomSQL is used on your site
## Server Version: 2020.1 Beta
#####
query listCustomSQLTables {
## Returns first 500 customSQLTables in this Site.
## Use 'offset' and script to fetch additional pages of results
customSQLTablesConnection(first: 500){
nodes {
# This is the actual SQL Statement
query
name
## Starting in 2020.1, the Database attribute will always
## be populated for CustomSQLTables, letting you figure out
## which databases are being used for CustomSQL queries the most
database {
name
connectionType
}
## This refers to the actual database tables the query references
## This attribute will be empty if the Metadata API/Catalog SQL Parser
## was unable to fully parse this SQL statement,.
tables {
name
}
}
}
}
query listCustomSQLTablesAndParents {
## Returns first 500 customSQLTables in this Site.
## Use 'offset' and script to fetch additional pages of results
customSQLTablesConnection(first: 500){
nodes {
# Un-comment the below to see the SQL statement
# query
name
columns {
## There are three paths under 'columns', each representing the different
## possibility of ownership. Option 1, a Flow owns this CustomSQLTable
## Option 2, a Published Data Source owns it. Option 3, a Workbook owns it.
## These options are mutually exclusive for a given CustomSQLTable.
## So only one of the three paths should terminate for a given SQLTable.
# Option 1: Owned by a Flow
referencedByFlowColumnInputField {
flow {
name
vizportalUrlId
}
}
referencedByFields {
datasource {
... on PublishedDatasource {
# Option 2: Owned by a published data source
name
}
... on EmbeddedDatasource {
workbook {
# Option 3: Owned by a workbook
name
}
}
}
}
}
}
}
}
## You need to filter the results down outside of the Metadata API
## to just those which have a "table.name" property filled
query workbooksOwningCustomSQL {
workbooksConnection(first: 100) {
nodes {
name
embeddedDatasources {
fields {
... on ColumnField {
columns {
table {
... on CustomSQLTable {
name
}
}
}
}
}
}
}
}
}
## You need to filter the results down outside of the Metadata API
## to just those which have a "table.name" property filled
query datasourceUsesCustomSQL {
publishedDatasources {
name
fields {
... on ColumnField{
columns {
table {
... on CustomSQLTable {
name
}
}
}
}
}
}
}