Skip to content

Commit

Permalink
Round percentages
Browse files Browse the repository at this point in the history
  • Loading branch information
JCZuurmond committed Oct 23, 2024
1 parent c70aa9b commit 593cdc4
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* --title 'Overall readiness (%)' --width 2 */
SELECT
100 * COUNT_IF(size(failures) = 0) / COUNT(*) AS percentage
ROUND(100 * COUNT_IF(size(failures) = 0) / COUNT(*), 2) AS percentage
FROM ucx_catalog.multiworkspace.latest_historical_per_workspace
WHERE object_type IN ('udfs', 'grants', 'jobs', 'clusters', 'tables', 'pipelines', 'policies')
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* --title 'UDF migration readiness (%)' */
SELECT
100 * COUNT_IF(size(failures) = 0) / COUNT(*) AS percentage
ROUND(100 * COUNT_IF(size(failures) = 0) / COUNT(*), 2) AS percentage
FROM ucx_catalog.multiworkspace.latest_historical_per_workspace
WHERE object_type = "udfs"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* --title 'Grant migration readiness (%)' */
SELECT
100 * COUNT_IF(size(failures) = 0) / COUNT(*) AS percentage
ROUND(100 * COUNT_IF(size(failures) = 0) / COUNT(*), 2) AS percentage
FROM ucx_catalog.multiworkspace.latest_historical_per_workspace
WHERE object_type = "grants"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* --title 'Job migration readiness (%)' */
SELECT
100 * COUNT_IF(size(failures) = 0) / COUNT(*) AS percentage
ROUND(100 * COUNT_IF(size(failures) = 0) / COUNT(*), 2) AS percentage
FROM ucx_catalog.multiworkspace.latest_historical_per_workspace
WHERE object_type = "jobs"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* --title 'Cluster migration readiness (%)' */
SELECT
100 * COUNT_IF(size(failures) = 0) / COUNT(*) AS percentage
ROUND(100 * COUNT_IF(size(failures) = 0) / COUNT(*), 2) AS percentage
FROM ucx_catalog.multiworkspace.latest_historical_per_workspace
WHERE object_type = "clusters"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* --title 'Table migration readiness (%)' --width 2 */
SELECT
100 * COUNT_IF(size(failures) = 0) / COUNT(*) AS percentage
ROUND(100 * COUNT_IF(size(failures) = 0) / COUNT(*), 2) AS percentage
FROM ucx_catalog.multiworkspace.latest_historical_per_workspace
WHERE object_type = "tables"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* --title 'Pipeline migration readiness (%)' */
SELECT
100 * COUNT_IF(size(failures) = 0) / COUNT(*) AS percentage
ROUND(100 * COUNT_IF(size(failures) = 0) / COUNT(*), 2) AS percentage
FROM ucx_catalog.multiworkspace.latest_historical_per_workspace
WHERE object_type = "pipelines"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* --title 'Policy migration readiness (%)' */
SELECT
100 * COUNT_IF(size(failures) = 0) / COUNT(*) AS percentage
ROUND(100 * COUNT_IF(size(failures) = 0) / COUNT(*), 2) AS percentage
FROM ucx_catalog.multiworkspace.latest_historical_per_workspace
WHERE object_type = "policies"
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ WITH migration_statuses AS (

SELECT
owner,
100 * COUNT_IF(SIZE(failures) = 0) / SUM(COUNT(*)) OVER (partition by owner) AS percentage,
ROUND(100 * COUNT_IF(SIZE(failures) = 0) / SUM(COUNT(*)) OVER (partition by owner), 2) AS percentage,
COUNT(*) AS total,
COUNT_IF(SIZE(failures) = 0) AS total_migrated,
COUNT_IF(SIZE(failures) > 0) AS total_not_migrated
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/queries/test_migration_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ def test_migration_progress_dashboard(
@pytest.mark.parametrize(
"query_name, rows",
[
("01_0_percentage_migration_readiness", [Row(percentage=73.91304347826087)]),
("01_0_percentage_migration_readiness", [Row(percentage=73.91)]),
("01_1_percentage_udf_migration_readiness", [Row(percentage=50.0)]),
("01_2_percentage_grant_migration_readiness", [Row(percentage=66.66666666666667)]),
("01_2_percentage_grant_migration_readiness", [Row(percentage=66.67)]),
("01_3_percentage_job_migration_readiness", [Row(percentage=50.0)]),
("01_4_percentage_cluster_migration_readiness", [Row(percentage=50.0)]),
("01_5_percentage_table_migration_readiness", [Row(percentage=100.0)]),
Expand All @@ -335,7 +335,7 @@ def test_migration_progress_dashboard(
"02_4_migration_status_by_owner_overview",
[
Row(owner="Andrew", percentage=50.0, total=2, total_migrated=1, total_not_migrated=1),
Row(owner="Cor", percentage=42.857142857142854, total=7, total_migrated=3, total_not_migrated=4),
Row(owner="Cor", percentage=42.86, total=7, total_migrated=3, total_not_migrated=4),
Row(owner="Eric", percentage=100.0, total=1, total_migrated=1, total_not_migrated=0),
],
),
Expand Down

0 comments on commit 593cdc4

Please sign in to comment.