Skip to content

Commit dfa350a

Browse files
Update existing and add new SQL queries to the assessment step dashboard (#269)
Fixes #268 --------- Co-authored-by: FastLee <[email protected]>
1 parent f7eab58 commit dfa350a

File tree

12 files changed

+111
-22
lines changed

12 files changed

+111
-22
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- viz type=table, name=Table Types, columns=database,name,type,format,table_view,storage,is_delta,location
2+
-- widget title=Table Types, col=0, row=3, size_x=6, size_y=6
3+
SELECT `database`,
4+
name,
5+
object_type AS type,
6+
UPPER(table_format) AS format,
7+
IF(object_type IN ("MANAGED", "EXTERNAL"), "TABLE", "VIEW") AS table_view,
8+
CASE
9+
WHEN STARTSWITH(location, "/dbfs/")
10+
AND NOT STARTSWITH(location, "/dbfs/mnt") THEN "DBFS ROOT"
11+
WHEN STARTSWITH(location, "/dbfs/mnt") THEN "DBFS MOUNT"
12+
ELSE "EXTERNAL"
13+
END AS storage,
14+
IF(format = "delta", "Yes", "No") AS is_delta,
15+
location
16+
FROM $inventory.tables
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- viz type=table, name=Clusters, columns=cluster_id,cluster_name,creator,compatible,failures
2+
-- widget title=Clusters, col=0, row=25, size_x=6, size_y=8
3+
SELECT cluster_id,
4+
cluster_name,
5+
creator,
6+
IF(success = 1, "Compatible", "Incompatible") AS compatible,
7+
failures
8+
FROM $inventory.clusters
9+
WHERE NOT STARTSWITH(cluster_name, "job-")
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- viz type=counter, name=Total Database Count, counter_label=Total Databases, value_column=count_total_databases
2+
-- widget col=0, row=0, size_x=1, size_y=3
3+
SELECT COUNT(DISTINCT `database`) AS count_total_databases
4+
FROM hive_metastore.ucx.tables
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- viz type=counter, name=Total Table Count, counter_label=Total Tables, value_column=count_total_tables
2+
-- widget col=1, row=0, size_x=1, size_y=3
3+
SELECT count(*) AS count_total_tables
4+
FROM $inventory.tables
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
-- viz type=table, name=Database Summary, columns=database,tables,views,dbfs_root,delta_tables,upgrade
2+
-- widget title=Database Summary, col=0, row=9, size_x=6, size_y=8
3+
SELECT `database`,
4+
SUM(is_table) AS tables,
5+
SUM(is_view) AS views,
6+
SUM(is_dbfs_root) AS dbfs_root,
7+
SUM(is_delta) AS delta_tables,
8+
CASE
9+
WHEN (SUM(is_dbfs_root)/SUM(is_table) > .3) THEN "Asset Replication Required"
10+
WHEN (SUM(is_delta)/SUM(is_table) < .7) THEN "Some Non Delta Assets"
11+
ELSE "In Place Sync"
12+
END AS upgrade
13+
FROM
14+
(SELECT DATABASE,
15+
name,
16+
object_type,
17+
UPPER(table_format) AS format,
18+
LOCATION,
19+
IF(object_type IN ("MANAGED", "EXTERNAL"), 1, 0) AS is_table,
20+
IF(object_type = "VIEW", 1, 0) AS is_view,
21+
IF(STARTSWITH(location, "/dbfs/") AND NOT STARTSWITH(location, "/dbfs/mnt"), 1, 0) AS is_dbfs_root,
22+
IF(UPPER(format) = "DELTA", 1, 0) AS is_delta
23+
FROM $inventory.tables)
24+
GROUP BY `database`
25+
ORDER BY `database`
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- viz type=table, name=External Locations, columns=location
2+
-- widget title=External Locations, col=0, row=17, size_x=3, size_y=8
3+
SELECT location
4+
FROM hive_metastore.ucx.external_locations
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- viz type=table, name=Jobs, columns=job_id,job_name,creator,compatible,failures
2+
-- widget title=Jobs, col=0, row=33, size_x=6, size_y=8
3+
SELECT job_id,
4+
job_name,
5+
creator,
6+
IF(success=1, "Compatible", "Incompatible") AS compatible,
7+
failures
8+
FROM $inventory.jobs
9+
WHERE job_name not like '[UCX]%'
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- viz type=table, name=Mount Points, columns=name,source
2+
-- widget title=Mount Points, col=3, row=17, size_x=3, size_y=8
3+
SELECT name,
4+
source
5+
FROM hive_metastore.ucx.mounts

src/databricks/labs/ucx/assessment/queries/total_tables.sql

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

src/databricks/labs/ucx/assessment/queries/workspace_access_total_groups.sql

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

0 commit comments

Comments
 (0)