From 593cdc4aadec8b71224482e90bcb9b7130cb016b Mon Sep 17 00:00:00 2001 From: Cor Zuurmond Date: Wed, 23 Oct 2024 14:47:04 +0200 Subject: [PATCH] Round percentages --- .../progress/main/01_0_percentage_migration_readiness.sql | 2 +- .../main/01_1_percentage_udf_migration_readiness.sql | 2 +- .../main/01_2_percentage_grant_migration_readiness.sql | 2 +- .../main/01_3_percentage_job_migration_readiness.sql | 2 +- .../main/01_4_percentage_cluster_migration_readiness.sql | 2 +- .../main/01_5_percentage_table_migration_readiness.sql | 2 +- .../main/01_6_percentage_pipeline_migration_readiness.sql | 2 +- .../main/01_7_percentage_policy_migration_readiness.sql | 2 +- .../main/02_4_migration_status_by_owner_overview.sql | 2 +- tests/integration/queries/test_migration_progress.py | 6 +++--- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/databricks/labs/ucx/queries/progress/main/01_0_percentage_migration_readiness.sql b/src/databricks/labs/ucx/queries/progress/main/01_0_percentage_migration_readiness.sql index e511167835..84a10d5372 100644 --- a/src/databricks/labs/ucx/queries/progress/main/01_0_percentage_migration_readiness.sql +++ b/src/databricks/labs/ucx/queries/progress/main/01_0_percentage_migration_readiness.sql @@ -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') diff --git a/src/databricks/labs/ucx/queries/progress/main/01_1_percentage_udf_migration_readiness.sql b/src/databricks/labs/ucx/queries/progress/main/01_1_percentage_udf_migration_readiness.sql index 5af678bfa5..ef856c2751 100644 --- a/src/databricks/labs/ucx/queries/progress/main/01_1_percentage_udf_migration_readiness.sql +++ b/src/databricks/labs/ucx/queries/progress/main/01_1_percentage_udf_migration_readiness.sql @@ -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" diff --git a/src/databricks/labs/ucx/queries/progress/main/01_2_percentage_grant_migration_readiness.sql b/src/databricks/labs/ucx/queries/progress/main/01_2_percentage_grant_migration_readiness.sql index 02912012ff..28754a4184 100644 --- a/src/databricks/labs/ucx/queries/progress/main/01_2_percentage_grant_migration_readiness.sql +++ b/src/databricks/labs/ucx/queries/progress/main/01_2_percentage_grant_migration_readiness.sql @@ -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" diff --git a/src/databricks/labs/ucx/queries/progress/main/01_3_percentage_job_migration_readiness.sql b/src/databricks/labs/ucx/queries/progress/main/01_3_percentage_job_migration_readiness.sql index b11a3a443a..91ebda361b 100644 --- a/src/databricks/labs/ucx/queries/progress/main/01_3_percentage_job_migration_readiness.sql +++ b/src/databricks/labs/ucx/queries/progress/main/01_3_percentage_job_migration_readiness.sql @@ -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" diff --git a/src/databricks/labs/ucx/queries/progress/main/01_4_percentage_cluster_migration_readiness.sql b/src/databricks/labs/ucx/queries/progress/main/01_4_percentage_cluster_migration_readiness.sql index 9f7e818104..280231c997 100644 --- a/src/databricks/labs/ucx/queries/progress/main/01_4_percentage_cluster_migration_readiness.sql +++ b/src/databricks/labs/ucx/queries/progress/main/01_4_percentage_cluster_migration_readiness.sql @@ -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" diff --git a/src/databricks/labs/ucx/queries/progress/main/01_5_percentage_table_migration_readiness.sql b/src/databricks/labs/ucx/queries/progress/main/01_5_percentage_table_migration_readiness.sql index 82a96df422..32d3ac58fa 100644 --- a/src/databricks/labs/ucx/queries/progress/main/01_5_percentage_table_migration_readiness.sql +++ b/src/databricks/labs/ucx/queries/progress/main/01_5_percentage_table_migration_readiness.sql @@ -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" diff --git a/src/databricks/labs/ucx/queries/progress/main/01_6_percentage_pipeline_migration_readiness.sql b/src/databricks/labs/ucx/queries/progress/main/01_6_percentage_pipeline_migration_readiness.sql index a7c9887afb..966eccaafa 100644 --- a/src/databricks/labs/ucx/queries/progress/main/01_6_percentage_pipeline_migration_readiness.sql +++ b/src/databricks/labs/ucx/queries/progress/main/01_6_percentage_pipeline_migration_readiness.sql @@ -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" diff --git a/src/databricks/labs/ucx/queries/progress/main/01_7_percentage_policy_migration_readiness.sql b/src/databricks/labs/ucx/queries/progress/main/01_7_percentage_policy_migration_readiness.sql index 09fb0d8edd..ce5f7e2da0 100644 --- a/src/databricks/labs/ucx/queries/progress/main/01_7_percentage_policy_migration_readiness.sql +++ b/src/databricks/labs/ucx/queries/progress/main/01_7_percentage_policy_migration_readiness.sql @@ -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" diff --git a/src/databricks/labs/ucx/queries/progress/main/02_4_migration_status_by_owner_overview.sql b/src/databricks/labs/ucx/queries/progress/main/02_4_migration_status_by_owner_overview.sql index 1be1b8ac7a..fcccb72ad4 100644 --- a/src/databricks/labs/ucx/queries/progress/main/02_4_migration_status_by_owner_overview.sql +++ b/src/databricks/labs/ucx/queries/progress/main/02_4_migration_status_by_owner_overview.sql @@ -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 diff --git a/tests/integration/queries/test_migration_progress.py b/tests/integration/queries/test_migration_progress.py index 9aee6582a9..33a1033a5d 100644 --- a/tests/integration/queries/test_migration_progress.py +++ b/tests/integration/queries/test_migration_progress.py @@ -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)]), @@ -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), ], ),