-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add linting resources to migration progress dashboard #3314
Draft
JCZuurmond
wants to merge
2
commits into
main
Choose a base branch
from
feat/add-code-migration-to-migration-progress-dashboard
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...5_percentage_table_migration_progress.sql → ...5_percentage_table_migration_progress.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/databricks/labs/ucx/queries/progress/main/01_06_percentage_used_table_progress.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* --title '"Table references in code" progress (%)' --description 'Tables referring UC over Hive metastore' */ | ||
SELECT | ||
ROUND(100 * TRY_DIVIDE(COUNT_IF(SIZE(failures) = 0), COUNT(*)), 2) AS percentage | ||
FROM ucx_catalog.multiworkspace.objects_snapshot | ||
WHERE object_type = "UsedTable" |
7 changes: 7 additions & 0 deletions
7
src/databricks/labs/ucx/queries/progress/main/01_07_count_direct_filesystem_access.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* --title 'Direct filesystem access progress (#)' --description 'Unsupported in Unity Catalog' */ | ||
SELECT COUNT(*) AS counter | ||
FROM ucx_catalog.multiworkspace.objects_snapshot | ||
WHERE object_type = "DirectFsAccess" | ||
-- Redundant filter as a direct filesystem access is a failure by definition (see description above), | ||
-- however, filter is defined for explicitness and as this knowledge is not "known" to this query. | ||
AND SIZE(failures) > 0 |
6 changes: 6 additions & 0 deletions
6
src/databricks/labs/ucx/queries/progress/main/01_08_count_query_problem.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* --title 'Query problem progress (#)' */ | ||
SELECT COUNT(*) AS counter | ||
FROM ucx_catalog.multiworkspace.objects_snapshot | ||
WHERE object_type = "QueryProblem" | ||
-- Redundant filter as a query problem is a failure by definition, however, filter is defined for explicitness | ||
AND SIZE(failures) > 0 |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/databricks/labs/ucx/queries/progress/main/02_4_migration_status_by_owner_overview.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Code | ||
|
||
This section shows Unity Catalog compatability issues found while linting code. There are two kinds of code changes to | ||
perform: | ||
- Data asset reference, like references to Hive metastore tables and views or direct filesystem access (dfsa). These | ||
references should be updated to refer to their Unity Catalog counterparts. | ||
- Linting compatability issues, like using RDDs or directly accessing the Spark context. These issues should be resolved | ||
by following the instructions stated with the issue. |
4 changes: 4 additions & 0 deletions
4
...tabricks/labs/ucx/queries/progress/main/03_01_pending_migration_data_asset_references.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* --title 'Pending migration' --description 'Total number of table, view and dfsa references' --height 6 */ | ||
SELECT COUNT(*) AS count | ||
FROM ucx_catalog.multiworkspace.objects_snapshot | ||
WHERE object_type IN ('DirectFsAccess', 'UsedTable') AND SIZE(failures) > 0 |
24 changes: 24 additions & 0 deletions
24
...abricks/labs/ucx/queries/progress/main/03_02_data_asset_references_by_owner_bar_graph.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
--title 'Pending migration' | ||
--description 'Tables, views and dfsa per owner' | ||
--width 5 | ||
--overrides '{"spec": { | ||
"version": 3, | ||
"widgetType": "bar", | ||
"encodings": { | ||
"x": {"fieldName": "owner", "scale": {"type": "categorical"}, "displayName": "owner"}, | ||
"y": {"fieldName": "count", "scale": {"type": "quantitative"}, "displayName": "count"} | ||
} | ||
}}' | ||
*/ | ||
WITH owners_with_failures AS ( | ||
SELECT owner | ||
FROM ucx_catalog.multiworkspace.objects_snapshot | ||
WHERE object_type IN ('DirectFsAccess', 'UsedTable') AND SIZE(failures) > 0 | ||
) | ||
|
||
SELECT | ||
owner, | ||
COUNT(1) AS count | ||
FROM owners_with_failures | ||
GROUP BY owner |
4 changes: 4 additions & 0 deletions
4
src/databricks/labs/ucx/queries/progress/main/03_03_migrated_data_asset_references.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* --title 'Migrated' --description 'Total number of table, view and dfsa references' --height 6 */ | ||
SELECT COUNT(*) AS count | ||
FROM ucx_catalog.multiworkspace.objects_snapshot | ||
WHERE object_type IN ('DirectFsAccess', 'UsedTable') AND SIZE(failures) == 0 |
20 changes: 20 additions & 0 deletions
20
...labs/ucx/queries/progress/main/03_04_data_asset_references_pending_migration_overview.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* --title 'Overview' --description 'Table, view and dfsa migration' --width 5 */ | ||
WITH migration_statuses AS ( | ||
SELECT owner, object_type, failures | ||
FROM ucx_catalog.multiworkspace.objects_snapshot | ||
WHERE object_type IN ('DirectFsAccess', 'UsedTable') | ||
) | ||
|
||
SELECT | ||
owner, | ||
CASE | ||
WHEN object_type = 'DirectFsAccess' THEN 'Direct filesystem access' | ||
WHEN object_type = 'UsedTable' THEN 'Table or view reference' | ||
ELSE object_type | ||
END AS object_type, | ||
DOUBLE(CEIL(100 * COUNT_IF(SIZE(failures) = 0) / SUM(COUNT(*)) OVER (PARTITION BY owner, object_type), 2)) AS percentage, | ||
COUNT(*) AS total, | ||
COUNT_IF(SIZE(failures) = 0) AS total_migrated, | ||
COUNT_IF(SIZE(failures) > 0) AS total_not_migrated | ||
FROM migration_statuses | ||
GROUP BY owner, object_type |
43 changes: 43 additions & 0 deletions
43
...tabricks/labs/ucx/queries/progress/main/03_05_data_asset_references_pending_migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
--title 'Data asset references' | ||
--width 6 | ||
--overrides '{"spec":{ | ||
"encodings":{ | ||
"columns": [ | ||
{"fieldName": "workspace_id", "booleanValues": ["false", "true"], "type": "string", "displayAs": "string", "title": "workspace_id"}, | ||
{"fieldName": "object_type", "booleanValues": ["false", "true"], "type": "string", "displayAs": "string", "title": "object_type"}, | ||
{"fieldName": "object_id", "booleanValues": ["false", "true"], "linkUrlTemplate": "{{ link }}", "linkTextTemplate": "{{ @ }}", "linkTitleTemplate": "{{ @ }}", "linkOpenInNewTab": true, "type": "string", "displayAs": "link", "title": "object_id"}, | ||
{"fieldName": "failure", "booleanValues": ["false", "true"], "type": "integer", "displayAs": "number", "title": "failure"}, | ||
{"fieldName": "is_read", "booleanValues": ["false", "true"], "type": "integer", "displayAs": "number", "title": "is_read"}, | ||
{"fieldName": "is_write", "booleanValues": ["false", "true"], "type": "integer", "displayAs": "number", "title": "is_write"} | ||
]}, | ||
"invisibleColumns": [ | ||
{"name": "link", "booleanValues": ["false", "true"], "linkUrlTemplate": "{{ @ }}", "linkTextTemplate": "{{ @ }}", "linkTitleTemplate": "{{ @ }}", "linkOpenInNewTab": true, "type": "string", "displayAs": "link", "title": "link"} | ||
] | ||
}}' | ||
*/ | ||
SELECT | ||
workspace_id, | ||
owner, | ||
CASE | ||
WHEN object_type = 'DirectFsAccess' THEN 'Direct filesystem access' | ||
WHEN object_type = 'UsedTable' THEN 'Table or view reference' | ||
ELSE object_type | ||
END AS object_type, | ||
CASE | ||
WHEN object_type = 'DirectFsAccess' THEN data.path | ||
WHEN object_type = 'UsedTable' THEN CONCAT_WS('.', object_id) | ||
ELSE CONCAT_WS('.', object_id) | ||
END AS object_id, | ||
EXPLODE(failures) AS failure, | ||
CAST(data.is_read AS BOOLEAN) AS is_read, | ||
CAST(data.is_write AS BOOLEAN) AS is_write, | ||
-- Below are invisible column(s) used in links url templates | ||
CASE | ||
-- SQL queries do NOT point to the workspace, i.e. start with '/' | ||
WHEN object_type = 'DirectFsAccess' AND SUBSTRING(data.source_id, 0, 1) != '/' THEN CONCAT('/sql/editor/', data.source_id) | ||
ELSE CONCAT('/#workspace', data.source_id) | ||
END AS link | ||
FROM ucx_catalog.multiworkspace.objects_snapshot | ||
ORDER BY workspace_id, owner, object_type, object_id | ||
WHERE object_type IN ('DirectFsAccess', 'UsedTable') |
29 changes: 29 additions & 0 deletions
29
src/databricks/labs/ucx/queries/progress/main/03_06_code_compatibility_issues.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
--title 'Code compatability issues' | ||
--width 6 | ||
--overrides '{"spec":{ | ||
"encodings":{ | ||
"columns": [ | ||
{"fieldName": "workspace_id", "booleanValues": ["false", "true"], "type": "string", "displayAs": "string", "title": "workspace_id"}, | ||
{"fieldName": "code", "booleanValues": ["false", "true"], "type": "string", "displayAs": "string", "title": "code"}, | ||
{"fieldName": "message", "booleanValues": ["false", "true"], "type": "string", "displayAs": "string", "title": "message"}, | ||
{"fieldName": "dashboard_name", "booleanValues": ["false", "true"], "linkUrlTemplate": "/sql/dashboards/{{ dashboard_id }}", "linkTextTemplate": "{{ @ }}", "linkTitleTemplate": "{{ @ }}", "linkOpenInNewTab": true, "type": "string", "displayAs": "link", "title": "dashboard"}, | ||
{"fieldName": "query_name", "booleanValues": ["false", "true"], "linkUrlTemplate": "/sql/editor/{{ query_id }}", "linkTextTemplate": "{{ @ }}", "linkTitleTemplate": "{{ @ }}", "linkOpenInNewTab": true, "type": "string", "displayAs": "link", "title": "query"} | ||
]}, | ||
"invisibleColumns": [ | ||
{"name": "dashboard_id", "booleanValues": ["false", "true"], "linkUrlTemplate": "{{ @ }}", "linkTextTemplate": "{{ @ }}", "linkTitleTemplate": "{{ @ }}", "linkOpenInNewTab": true, "type": "string", "displayAs": "link", "title": "dashboard_id"}, | ||
{"name": "query_id", "booleanValues": ["false", "true"], "linkUrlTemplate": "{{ @ }}", "linkTextTemplate": "{{ @ }}", "linkTitleTemplate": "{{ @ }}", "linkOpenInNewTab": true, "type": "string", "displayAs": "link", "title": "query_id"} | ||
] | ||
}}' | ||
*/ | ||
SELECT | ||
workspace_id, | ||
data.code, | ||
data.message, | ||
data.dashboard_name, | ||
data.query_name, | ||
-- Below are invisible columns used in links url templates | ||
data.dashboard_id, | ||
data.query_id | ||
FROM ucx_catalog.multiworkspace.objects_snapshot | ||
WHERE object_type = 'QueryProblem' |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
directfs access, query, usedtable - they're not top-level entities per se, but jobs, pipelines, dashboards - are