From d9293a7ec1462bc3fd6a3f80ec4303d63ec74867 Mon Sep 17 00:00:00 2001 From: Onkar Ravgan Date: Wed, 25 Oct 2023 21:03:08 +0530 Subject: [PATCH 1/2] fixed nan in aggregations --- .../AggregatedUsedvsUnusedAssetsCountAggregator.java | 9 ++++++--- .../AggregatedUsedvsUnusedAssetsSizeAggregator.java | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/dataInsight/AggregatedUsedvsUnusedAssetsCountAggregator.java b/openmetadata-service/src/main/java/org/openmetadata/service/dataInsight/AggregatedUsedvsUnusedAssetsCountAggregator.java index 048a7ce25c91..24da7eb3a6a4 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/dataInsight/AggregatedUsedvsUnusedAssetsCountAggregator.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/dataInsight/AggregatedUsedvsUnusedAssetsCountAggregator.java @@ -26,9 +26,12 @@ public List aggregate() throws ParseException { Double used = Objects.requireNonNullElse(getValue(totalUsed), 0.0); Double unused = Objects.requireNonNullElse(getValue(totalUnused), 0.0); Double total = used + unused; - Double usedPercentage = used / total; - Double unusedPercentage = unused / total; - + Double usedPercentage = 0.0; + Double unusedPercentage = 0.0; + if(total != 0){ + usedPercentage = used / total; + unusedPercentage = unused / total; + } data.add( new AggregatedUsedVsUnusedAssetsCount() .withTimestamp(timestamp) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/dataInsight/AggregatedUsedvsUnusedAssetsSizeAggregator.java b/openmetadata-service/src/main/java/org/openmetadata/service/dataInsight/AggregatedUsedvsUnusedAssetsSizeAggregator.java index 5208caf76ee8..d10648e2a543 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/dataInsight/AggregatedUsedvsUnusedAssetsSizeAggregator.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/dataInsight/AggregatedUsedvsUnusedAssetsSizeAggregator.java @@ -25,9 +25,12 @@ public List aggregate() throws ParseException { Double used = Objects.requireNonNullElse(getValue(totalUsed), 0.0); Double unused = Objects.requireNonNullElse(getValue(totalUnused), 0.0); Double total = used + unused; - Double usedPercentage = used / total; - Double unusedPercentage = unused / total; - + Double usedPercentage = 0.0; + Double unusedPercentage = 0.0; + if(total != 0){ + usedPercentage = used / total; + unusedPercentage = unused / total; + } data.add( new AggregatedUsedVsUnusedAssetsSize() .withTimestamp(timestamp) From 2e2370f0f08bab8b275addd4031a646f8cbae916 Mon Sep 17 00:00:00 2001 From: Onkar Ravgan Date: Wed, 25 Oct 2023 21:13:21 +0530 Subject: [PATCH 2/2] review comments --- .../AggregatedUsedvsUnusedAssetsCountAggregator.java | 2 +- .../dataInsight/AggregatedUsedvsUnusedAssetsSizeAggregator.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/dataInsight/AggregatedUsedvsUnusedAssetsCountAggregator.java b/openmetadata-service/src/main/java/org/openmetadata/service/dataInsight/AggregatedUsedvsUnusedAssetsCountAggregator.java index 24da7eb3a6a4..55da7c43ff35 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/dataInsight/AggregatedUsedvsUnusedAssetsCountAggregator.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/dataInsight/AggregatedUsedvsUnusedAssetsCountAggregator.java @@ -28,7 +28,7 @@ public List aggregate() throws ParseException { Double total = used + unused; Double usedPercentage = 0.0; Double unusedPercentage = 0.0; - if(total != 0){ + if (total != 0.0) { usedPercentage = used / total; unusedPercentage = unused / total; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/dataInsight/AggregatedUsedvsUnusedAssetsSizeAggregator.java b/openmetadata-service/src/main/java/org/openmetadata/service/dataInsight/AggregatedUsedvsUnusedAssetsSizeAggregator.java index d10648e2a543..c308befe3d39 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/dataInsight/AggregatedUsedvsUnusedAssetsSizeAggregator.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/dataInsight/AggregatedUsedvsUnusedAssetsSizeAggregator.java @@ -27,7 +27,7 @@ public List aggregate() throws ParseException { Double total = used + unused; Double usedPercentage = 0.0; Double unusedPercentage = 0.0; - if(total != 0){ + if (total != 0.0) { usedPercentage = used / total; unusedPercentage = unused / total; }