From b89f5eaad07cc78b408df84378d96df4805d804a Mon Sep 17 00:00:00 2001 From: Onkar Ravgan Date: Thu, 26 Oct 2023 00:18:05 +0530 Subject: [PATCH] Fixed NaN values in Cost Analysis aggregate APIs (#13708) * fixed nan in aggregations * review comments --- .../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..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 @@ -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.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..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 @@ -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.0) { + usedPercentage = used / total; + unusedPercentage = unused / total; + } data.add( new AggregatedUsedVsUnusedAssetsSize() .withTimestamp(timestamp)