FIXES #14294: return null if no aggregation value is present (#14514)

* fix: return null is no aggregation value is present

* fix: added Optional typing

* style: java linting

* fix: use Optional type hint

* style: java linting
This commit is contained in:
Teddy 2023-12-29 08:05:36 +01:00 committed by GitHub
parent 1f4ab99122
commit 2f679a9a48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 196 additions and 124 deletions

View File

@ -3,6 +3,7 @@ package org.openmetadata.service.dataInsight;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.openmetadata.schema.analytics.DataAssetValues;
import org.openmetadata.schema.dataInsight.type.AggregatedUnusedAssetsCount;
@ -62,5 +63,5 @@ public abstract class AggregatedUnusedAssetsCountAggregator<A, H, B, S>
protected abstract S getAggregations(B bucket, String key);
protected abstract Double getValue(S aggregations);
protected abstract Optional<Double> getValue(S aggregations);
}

View File

@ -3,6 +3,7 @@ package org.openmetadata.service.dataInsight;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.openmetadata.schema.analytics.DataAssetValues;
import org.openmetadata.schema.dataInsight.type.AggregatedUnusedAssetsSize;
@ -62,5 +63,5 @@ public abstract class AggregatedUnusedAssetsSizeAggregator<A, H, B, S>
protected abstract S getAggregations(B bucket, String key);
protected abstract Double getValue(S aggregations);
protected abstract Optional<Double> getValue(S aggregations);
}

View File

@ -3,7 +3,7 @@ package org.openmetadata.service.dataInsight;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import org.openmetadata.schema.dataInsight.type.AggregatedUsedVsUnusedAssetsCount;
public abstract class AggregatedUsedvsUnusedAssetsCountAggregator<A, H, B, S>
@ -23,21 +23,17 @@ public abstract class AggregatedUsedvsUnusedAssetsCountAggregator<A, H, B, S>
Long timestamp = convertDatTimeStringToTimestamp(dateTimeString);
S totalUnused = getAggregations(bucket, "totalUnused");
S totalUsed = getAggregations(bucket, "totalUsed");
Double used = Objects.requireNonNullElse(getValue(totalUsed), 0.0);
Double unused = Objects.requireNonNullElse(getValue(totalUnused), 0.0);
Double total = used + unused;
double usedPercentage = 0.0;
double unusedPercentage = 0.0;
if (total != 0.0) {
usedPercentage = used / total;
unusedPercentage = unused / total;
}
Optional<Double> used = getValue(totalUsed);
Optional<Double> unused = getValue(totalUnused);
Optional<Double> total = used.flatMap(u -> unused.map(uu -> u + uu));
Double usedPercentage = used.flatMap(u -> total.map(t -> u / t)).orElse(null);
Double unusedPercentage = unused.flatMap(uu -> total.map(t -> uu / t)).orElse(null);
data.add(
new AggregatedUsedVsUnusedAssetsCount()
.withTimestamp(timestamp)
.withUnused(unused)
.withUnused(unused.orElse(null))
.withUnusedPercentage(unusedPercentage)
.withUsed(used)
.withUsed(used.orElse(null))
.withUsedPercentage(usedPercentage));
}
return data;
@ -51,5 +47,5 @@ public abstract class AggregatedUsedvsUnusedAssetsCountAggregator<A, H, B, S>
protected abstract S getAggregations(B bucket, String key);
protected abstract Double getValue(S aggregations);
protected abstract Optional<Double> getValue(S aggregations);
}

View File

@ -3,7 +3,7 @@ package org.openmetadata.service.dataInsight;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import org.openmetadata.schema.dataInsight.type.AggregatedUsedVsUnusedAssetsSize;
public abstract class AggregatedUsedvsUnusedAssetsSizeAggregator<A, H, B, S>
@ -23,21 +23,17 @@ public abstract class AggregatedUsedvsUnusedAssetsSizeAggregator<A, H, B, S>
Long timestamp = convertDatTimeStringToTimestamp(dateTimeString);
S totalUnused = getAggregations(bucket, "totalUnused");
S totalUsed = getAggregations(bucket, "totalUsed");
Double used = Objects.requireNonNullElse(getValue(totalUsed), 0.0);
Double unused = Objects.requireNonNullElse(getValue(totalUnused), 0.0);
Double total = used + unused;
double usedPercentage = 0.0;
double unusedPercentage = 0.0;
if (total != 0.0) {
usedPercentage = used / total;
unusedPercentage = unused / total;
}
Optional<Double> used = getValue(totalUsed);
Optional<Double> unused = getValue(totalUnused);
Optional<Double> total = used.flatMap(u -> unused.map(uu -> u + uu));
Double usedPercentage = used.flatMap(u -> total.map(t -> u / t)).orElse(null);
Double unusedPercentage = unused.flatMap(uu -> total.map(t -> uu / t)).orElse(null);
data.add(
new AggregatedUsedVsUnusedAssetsSize()
.withTimestamp(timestamp)
.withUnused(unused)
.withUnused(unused.orElse(null))
.withUnusedPercentage(unusedPercentage)
.withUsed(used)
.withUsed(used.orElse(null))
.withUsedPercentage(usedPercentage));
}
return data;
@ -51,5 +47,5 @@ public abstract class AggregatedUsedvsUnusedAssetsSizeAggregator<A, H, B, S>
protected abstract S getAggregations(B bucket, String key);
protected abstract Double getValue(S aggregations);
protected abstract Optional<Double> getValue(S aggregations);
}

View File

@ -3,6 +3,7 @@ package org.openmetadata.service.dataInsight;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.openmetadata.schema.dataInsight.type.PercentageOfEntitiesWithDescriptionByType;
public abstract class EntitiesDescriptionAggregator<A, B, M, S>
@ -26,15 +27,18 @@ public abstract class EntitiesDescriptionAggregator<A, B, M, S>
S sumCompletedDescriptions =
getAggregations(entityTypeBucket, COMPLETED_DESCRIPTION_FRACTION);
S sumEntityCount = getAggregations(entityTypeBucket, ENTITY_COUNT);
Optional<Double> entityCount = getValue(sumEntityCount);
Optional<Double> completedDescription = getValue(sumCompletedDescriptions);
Double completedDescriptionFraction =
completedDescription.flatMap(cd -> entityCount.map(ec -> cd / ec)).orElse(null);
data.add(
new PercentageOfEntitiesWithDescriptionByType()
.withTimestamp(timestamp)
.withEntityType(entityType)
.withEntityCount(getValue(sumEntityCount))
.withCompletedDescription(getValue(sumCompletedDescriptions))
.withCompletedDescriptionFraction(
getValue(sumCompletedDescriptions) / getValue(sumEntityCount)));
.withEntityCount(entityCount.orElse(null))
.withCompletedDescription(completedDescription.orElse(null))
.withCompletedDescriptionFraction(completedDescriptionFraction));
}
}
return data;
@ -50,5 +54,5 @@ public abstract class EntitiesDescriptionAggregator<A, B, M, S>
protected abstract S getAggregations(B bucket, String key);
protected abstract Double getValue(S aggregations);
protected abstract Optional<Double> getValue(S aggregations);
}

View File

@ -3,6 +3,7 @@ package org.openmetadata.service.dataInsight;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.openmetadata.schema.dataInsight.type.PercentageOfEntitiesWithOwnerByType;
public abstract class EntitiesOwnerAggregator<A, B, M, S>
@ -25,20 +26,24 @@ public abstract class EntitiesOwnerAggregator<A, B, M, S>
String entityType = getKeyAsString(entityTypeBucket);
S sumHasOwner = getAggregations(entityTypeBucket, HAS_OWNER_FRACTION);
S sumEntityCount = getAggregations(entityTypeBucket, ENTITY_COUNT);
Optional<Double> entityCount = getValue(sumEntityCount);
Optional<Double> hasOwner = getValue(sumHasOwner);
Double hasOwnerFraction =
hasOwner.flatMap(ho -> entityCount.map(ec -> ho / ec)).orElse(null);
data.add(
new PercentageOfEntitiesWithOwnerByType()
.withTimestamp(timestamp)
.withEntityType(entityType)
.withEntityCount(getValue(sumEntityCount))
.withHasOwner(getValue(sumHasOwner))
.withHasOwnerFraction(getValue(sumHasOwner) / getValue(sumEntityCount)));
.withEntityCount(entityCount.orElse(null))
.withHasOwner(hasOwner.orElse(null))
.withHasOwnerFraction(hasOwnerFraction));
}
}
return data;
}
protected abstract Double getValue(S sumEntityCount);
protected abstract Optional<Double> getValue(S sumEntityCount);
protected abstract S getAggregations(B entityTypeBucket, String key);

View File

@ -2,6 +2,7 @@ package org.openmetadata.service.dataInsight;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.openmetadata.schema.dataInsight.type.MostActiveUsers;
public abstract class MostActiveUsersAggregator<A, B, M, S, X>
@ -28,23 +29,32 @@ public abstract class MostActiveUsersAggregator<A, B, M, S, X>
// we'll assign the first team in the list if user belongs to multiple teams
team = getKeyAsString(getBuckets(teamBucket).get(0));
}
Optional<Long> lastSessionOptional = getMaxValue(lastSession);
Optional<Double> sumPageViewsOptional = getSumValue(sumPageViews);
Optional<Double> sumSessionDurationOptional = getSumValue(sumSessionDuration);
Optional<Double> sumSessionOptional = getSumValue(sumSession);
Double avgSessionDuration =
sumSessionDurationOptional
.flatMap(s -> sumSessionOptional.map(ss -> s / ss))
.orElse(null);
data.add(
new MostActiveUsers()
.withUserName(userName)
.withLastSession(getMaxValue(lastSession))
.withPageViews(getSumValue(sumPageViews))
.withSessionDuration(getSumValue(sumSessionDuration))
.withSessions(getSumValue(sumSession))
.withLastSession(lastSessionOptional.orElse(null))
.withPageViews(sumPageViewsOptional.orElse(null))
.withSessionDuration(sumSessionDurationOptional.orElse(null))
.withSessions(sumSessionOptional.orElse(null))
.withTeam(team)
.withAvgSessionDuration(getSumValue(sumSessionDuration) / getSumValue(sumSession)));
.withAvgSessionDuration(avgSessionDuration));
}
return data;
}
protected abstract Double getSumValue(S key);
protected abstract Optional<Double> getSumValue(S key);
protected abstract Long getMaxValue(X key);
protected abstract Optional<Long> getMaxValue(X key);
protected abstract String getKeyAsString(B bucket);

View File

@ -2,6 +2,7 @@ package org.openmetadata.service.dataInsight;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.openmetadata.schema.dataInsight.type.MostViewedEntities;
public abstract class MostViewedEntitiesAggregator<A, B, M, S>
@ -25,6 +26,7 @@ public abstract class MostViewedEntitiesAggregator<A, B, M, S>
String owner = getFirstValueFromBucketOrNull(ownerBucket);
String entityType = getFirstValueFromBucketOrNull(entityTypeBucket);
String entityHref = getFirstValueFromBucketOrNull(entityHrefBucket);
Optional<Double> pageViews = getValue(sumPageViews);
data.add(
new MostViewedEntities()
@ -32,13 +34,13 @@ public abstract class MostViewedEntitiesAggregator<A, B, M, S>
.withOwner(owner)
.withEntityType(entityType)
.withEntityHref(entityHref)
.withPageViews(getValue(sumPageViews)));
.withPageViews(pageViews.orElse(null)));
}
return data;
}
protected abstract Double getValue(S sumPageViews);
protected abstract Optional<Double> getValue(S sumPageViews);
protected abstract M getBucketAggregation(B bucket, String key);

View File

@ -3,6 +3,7 @@ package org.openmetadata.service.dataInsight;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.openmetadata.schema.dataInsight.type.PageViewsByEntities;
public abstract class PageViewsByEntitiesAggregator<A, B, M, S>
@ -24,18 +25,19 @@ public abstract class PageViewsByEntitiesAggregator<A, B, M, S>
for (B entityTypeBucket : getBuckets(entityTypeBuckets)) {
String entityType = getKeyAsString(entityTypeBucket);
S sumPageViews = getSumAggregations(entityTypeBucket, "pageViews");
Optional<Double> pageViews = getValue(sumPageViews);
data.add(
new PageViewsByEntities()
.withEntityType(entityType)
.withTimestamp(timestamp)
.withPageViews(getValue(sumPageViews)));
.withPageViews(pageViews.orElse(null)));
}
}
return data;
}
protected abstract Double getValue(S key);
protected abstract Optional<Double> getValue(S key);
protected abstract S getSumAggregations(B bucket, String key);

View File

@ -3,6 +3,7 @@ package org.openmetadata.service.dataInsight;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.openmetadata.schema.dataInsight.type.PercentageOfServicesWithDescription;
public abstract class ServicesDescriptionAggregator<A, B, M, S>
@ -26,21 +27,24 @@ public abstract class ServicesDescriptionAggregator<A, B, M, S>
S sumCompletedDescriptions =
getSumAggregations(serviceBucket, COMPLETED_DESCRIPTION_FRACTION);
S sumEntityCount = getSumAggregations(serviceBucket, ENTITY_COUNT);
Optional<Double> completedDescription = getValue(sumCompletedDescriptions);
Optional<Double> entityCount = getValue(sumEntityCount);
Double completedDescriptionFraction =
completedDescription.flatMap(cdf -> entityCount.map(ec -> cdf / ec)).orElse(null);
data.add(
new PercentageOfServicesWithDescription()
.withTimestamp(timestamp)
.withServiceName(serviceName)
.withEntityCount(getValue(sumEntityCount))
.withCompletedDescription(getValue(sumCompletedDescriptions))
.withCompletedDescriptionFraction(
getValue(sumCompletedDescriptions) / getValue(sumEntityCount)));
.withEntityCount(entityCount.orElse(null))
.withCompletedDescription(completedDescription.orElse(null))
.withCompletedDescriptionFraction(completedDescriptionFraction));
}
}
return data;
}
protected abstract Double getValue(S key);
protected abstract Optional<Double> getValue(S key);
protected abstract S getSumAggregations(B bucket, String key);

View File

@ -3,6 +3,7 @@ package org.openmetadata.service.dataInsight;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.openmetadata.schema.dataInsight.type.PercentageOfServicesWithOwner;
public abstract class ServicesOwnerAggregator<A, B, M, S>
@ -25,20 +26,24 @@ public abstract class ServicesOwnerAggregator<A, B, M, S>
String serviceName = getKeyAsString(serviceBucket);
S sumHasOwner = getSumAggregations(serviceBucket, HAS_OWNER_FRACTION);
S sumEntityCount = getSumAggregations(serviceBucket, ENTITY_COUNT);
Optional<Double> entityCount = getValue(sumEntityCount);
Optional<Double> hasOwner = getValue(sumHasOwner);
Double hasOwnerFraction =
hasOwner.flatMap(hof -> entityCount.map(ec -> hof / ec)).orElse(null);
data.add(
new PercentageOfServicesWithOwner()
.withTimestamp(timestamp)
.withServiceName(serviceName)
.withEntityCount(getValue(sumEntityCount))
.withHasOwner(getValue(sumHasOwner))
.withHasOwnerFraction(getValue(sumHasOwner) / getValue(sumEntityCount)));
.withEntityCount(entityCount.orElse(null))
.withHasOwner(hasOwner.orElse(null))
.withHasOwnerFraction(hasOwnerFraction));
}
}
return data;
}
protected abstract Double getValue(S key);
protected abstract Optional<Double> getValue(S key);
protected abstract S getSumAggregations(B bucket, String key);

View File

@ -3,6 +3,7 @@ package org.openmetadata.service.dataInsight;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.openmetadata.schema.dataInsight.type.TotalEntitiesByType;
public abstract class TotalEntitiesAggregator<A, B, M, S>
@ -26,13 +27,14 @@ public abstract class TotalEntitiesAggregator<A, B, M, S>
for (B entityTypeBucket : getBuckets(entityTypeBuckets)) {
String entityType = getKeyAsString(entityTypeBucket);
S sumEntityCount = getSumAggregations(entityTypeBucket, ENTITY_COUNT);
Optional<Double> entityCountOptional = getValue(sumEntityCount);
data.add(
new TotalEntitiesByType()
.withTimestamp(timestamp)
.withEntityType(entityType)
.withEntityCount(getValue(sumEntityCount)));
entityCount.add(getValue(sumEntityCount));
.withEntityCount(entityCountOptional.orElse(null)));
entityCount.add(entityCountOptional.orElse(0.0));
}
}
@ -46,7 +48,7 @@ public abstract class TotalEntitiesAggregator<A, B, M, S>
return data;
}
protected abstract Double getValue(S key);
protected abstract Optional<Double> getValue(S key);
protected abstract S getSumAggregations(B bucket, String key);

View File

@ -3,6 +3,7 @@ package org.openmetadata.service.dataInsight;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.openmetadata.schema.dataInsight.type.TotalEntitiesByTier;
public abstract class TotalEntitiesByTierAggregator<A, B, M, S>
@ -27,12 +28,14 @@ public abstract class TotalEntitiesByTierAggregator<A, B, M, S>
for (B entityTierBucket : getBuckets(entityTierBuckets)) {
String entityTier = getKeyAsString(entityTierBucket);
S sumEntityCount = getSumAggregations(entityTierBucket, ENTITY_COUNT);
Optional<Double> entityCount = getValue(sumEntityCount);
timestampData.add(
new TotalEntitiesByTier()
.withTimestamp(timestamp)
.withEntityTier(entityTier)
.withEntityCount(getValue(sumEntityCount)));
totalEntityCount = totalEntityCount + getValue(sumEntityCount);
.withEntityCount(entityCount.orElse(null)));
totalEntityCount = totalEntityCount + entityCount.orElse(0.0);
}
for (TotalEntitiesByTier el : timestampData) {
if (totalEntityCount != 0.0) {
@ -46,7 +49,7 @@ public abstract class TotalEntitiesByTierAggregator<A, B, M, S>
return data;
}
protected abstract Double getValue(S key);
protected abstract Optional<Double> getValue(S key);
protected abstract S getSumAggregations(B bucket, String key);

View File

@ -5,6 +5,7 @@ import es.org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import es.org.elasticsearch.search.aggregations.bucket.histogram.Histogram.Bucket;
import es.org.elasticsearch.search.aggregations.metrics.Sum;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.AggregatedUnusedAssetsCountAggregator;
public class ElasticSearchAggregatedUnusedAssetsCountAggregator
@ -34,7 +35,7 @@ public class ElasticSearchAggregatedUnusedAssetsCountAggregator
}
@Override
protected Double getValue(Sum aggregations) {
return aggregations != null ? aggregations.getValue() : 0.0;
protected Optional<Double> getValue(Sum aggregations) {
return Optional.ofNullable(aggregations != null ? aggregations.getValue() : null);
}
}

View File

@ -5,6 +5,7 @@ import es.org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import es.org.elasticsearch.search.aggregations.bucket.histogram.Histogram.Bucket;
import es.org.elasticsearch.search.aggregations.metrics.Sum;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.AggregatedUnusedAssetsSizeAggregator;
public class ElasticSearchAggregatedUnusedAssetsSizeAggregator
@ -34,7 +35,7 @@ public class ElasticSearchAggregatedUnusedAssetsSizeAggregator
}
@Override
protected Double getValue(Sum aggregations) {
return aggregations != null ? aggregations.getValue() : 0.0;
protected Optional<Double> getValue(Sum aggregations) {
return Optional.ofNullable(aggregations != null ? aggregations.getValue() : null);
}
}

View File

@ -5,6 +5,7 @@ import es.org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import es.org.elasticsearch.search.aggregations.bucket.histogram.Histogram.Bucket;
import es.org.elasticsearch.search.aggregations.metrics.Sum;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.AggregatedUsedvsUnusedAssetsCountAggregator;
public class ElasticSearchAggregatedUsedvsUnusedAssetsCountAggregator
@ -34,7 +35,7 @@ public class ElasticSearchAggregatedUsedvsUnusedAssetsCountAggregator
}
@Override
protected Double getValue(Sum aggregations) {
return aggregations != null ? aggregations.getValue() : 0.0;
protected Optional<Double> getValue(Sum aggregations) {
return Optional.ofNullable(aggregations != null ? aggregations.getValue() : null);
}
}

View File

@ -5,6 +5,7 @@ import es.org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import es.org.elasticsearch.search.aggregations.bucket.histogram.Histogram.Bucket;
import es.org.elasticsearch.search.aggregations.metrics.Sum;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.AggregatedUsedvsUnusedAssetsSizeAggregator;
public class ElasticSearchAggregatedUsedvsUnusedAssetsSizeAggregator
@ -34,7 +35,7 @@ public class ElasticSearchAggregatedUsedvsUnusedAssetsSizeAggregator
}
@Override
protected Double getValue(Sum aggregations) {
return aggregations != null ? aggregations.getValue() : 0.0;
protected Optional<Double> getValue(Sum aggregations) {
return Optional.ofNullable(aggregations != null ? aggregations.getValue() : null);
}
}

View File

@ -4,6 +4,7 @@ import es.org.elasticsearch.search.aggregations.Aggregations;
import es.org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
import es.org.elasticsearch.search.aggregations.metrics.Sum;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.EntitiesDescriptionAggregator;
public class ElasticSearchEntitiesDescriptionAggregator
@ -42,7 +43,7 @@ public class ElasticSearchEntitiesDescriptionAggregator
}
@Override
protected Double getValue(Sum aggregations) {
return aggregations != null ? aggregations.getValue() : 0.0;
protected Optional<Double> getValue(Sum aggregations) {
return Optional.ofNullable(aggregations != null ? aggregations.getValue() : null);
}
}

View File

@ -4,6 +4,7 @@ import es.org.elasticsearch.search.aggregations.Aggregations;
import es.org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
import es.org.elasticsearch.search.aggregations.metrics.Sum;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.EntitiesOwnerAggregator;
public class ElasticSearchEntitiesOwnerAggregator
@ -15,8 +16,8 @@ public class ElasticSearchEntitiesOwnerAggregator
}
@Override
protected Double getValue(Sum key) {
return key != null ? key.getValue() : 0.0;
protected Optional<Double> getValue(Sum key) {
return Optional.ofNullable(key != null ? key.getValue() : null);
}
@Override

View File

@ -5,6 +5,7 @@ import es.org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
import es.org.elasticsearch.search.aggregations.metrics.Max;
import es.org.elasticsearch.search.aggregations.metrics.Sum;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.MostActiveUsersAggregator;
public class ElasticSearchMostActiveUsersAggregator
@ -16,13 +17,13 @@ public class ElasticSearchMostActiveUsersAggregator
}
@Override
protected Double getSumValue(Sum key) {
return key != null ? key.getValue() : 0.0;
protected Optional<Double> getSumValue(Sum key) {
return Optional.ofNullable(key != null ? key.getValue() : null);
}
@Override
protected Long getMaxValue(Max key) {
return key != null ? (long) key.getValue() : 0;
protected Optional<Long> getMaxValue(Max key) {
return Optional.ofNullable(key != null ? (long) key.getValue() : null);
}
@Override

View File

@ -4,6 +4,7 @@ import es.org.elasticsearch.search.aggregations.Aggregations;
import es.org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
import es.org.elasticsearch.search.aggregations.metrics.Sum;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.MostViewedEntitiesAggregator;
public class ElasticSearchMostViewedEntitiesAggregator
@ -14,8 +15,8 @@ public class ElasticSearchMostViewedEntitiesAggregator
}
@Override
protected Double getValue(Sum key) {
return key != null ? key.getValue() : 0.0;
protected Optional<Double> getValue(Sum key) {
return Optional.ofNullable(key != null ? key.getValue() : null);
}
@Override

View File

@ -4,6 +4,7 @@ import es.org.elasticsearch.search.aggregations.Aggregations;
import es.org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
import es.org.elasticsearch.search.aggregations.metrics.Sum;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.PageViewsByEntitiesAggregator;
public class ElasticSearchPageViewsByEntitiesAggregator
@ -15,8 +16,8 @@ public class ElasticSearchPageViewsByEntitiesAggregator
}
@Override
protected Double getValue(Sum key) {
return key != null ? key.getValue() : 0.0;
protected Optional<Double> getValue(Sum key) {
return Optional.ofNullable(key != null ? key.getValue() : null);
}
@Override

View File

@ -4,6 +4,7 @@ import es.org.elasticsearch.search.aggregations.Aggregations;
import es.org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
import es.org.elasticsearch.search.aggregations.metrics.Sum;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.ServicesDescriptionAggregator;
public class ElasticSearchServicesDescriptionAggregator
@ -14,8 +15,8 @@ public class ElasticSearchServicesDescriptionAggregator
}
@Override
protected Double getValue(Sum key) {
return key != null ? key.getValue() : 0.0;
protected Optional<Double> getValue(Sum key) {
return Optional.ofNullable(key != null ? key.getValue() : null);
}
@Override

View File

@ -4,6 +4,7 @@ import es.org.elasticsearch.search.aggregations.Aggregations;
import es.org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
import es.org.elasticsearch.search.aggregations.metrics.Sum;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.ServicesOwnerAggregator;
public class ElasticSearchServicesOwnerAggregator
@ -14,8 +15,8 @@ public class ElasticSearchServicesOwnerAggregator
}
@Override
protected Double getValue(Sum key) {
return key != null ? key.getValue() : 0.0;
protected Optional<Double> getValue(Sum key) {
return Optional.ofNullable(key != null ? key.getValue() : null);
}
@Override

View File

@ -4,6 +4,7 @@ import es.org.elasticsearch.search.aggregations.Aggregations;
import es.org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
import es.org.elasticsearch.search.aggregations.metrics.Sum;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.TotalEntitiesAggregator;
public class ElasticSearchTotalEntitiesAggregator
@ -14,8 +15,8 @@ public class ElasticSearchTotalEntitiesAggregator
}
@Override
protected Double getValue(Sum key) {
return key != null ? key.getValue() : 0.0;
protected Optional<Double> getValue(Sum key) {
return Optional.ofNullable(key != null ? key.getValue() : null);
}
@Override

View File

@ -4,6 +4,7 @@ import es.org.elasticsearch.search.aggregations.Aggregations;
import es.org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
import es.org.elasticsearch.search.aggregations.metrics.Sum;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.TotalEntitiesByTierAggregator;
public class ElasticSearchTotalEntitiesByTierAggregator
@ -14,8 +15,8 @@ public class ElasticSearchTotalEntitiesByTierAggregator
}
@Override
protected Double getValue(Sum key) {
return key != null ? key.getValue() : 0.0;
protected Optional<Double> getValue(Sum key) {
return Optional.ofNullable(key != null ? key.getValue() : null);
}
@Override

View File

@ -1,6 +1,7 @@
package org.openmetadata.service.search.opensearch.dataInsightAggregator;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.AggregatedUnusedAssetsCountAggregator;
import os.org.opensearch.search.aggregations.Aggregations;
import os.org.opensearch.search.aggregations.bucket.histogram.Histogram;
@ -34,7 +35,7 @@ public class OpenSearchAggregatedUnusedAssetsCountAggregator
}
@Override
protected Double getValue(Sum aggregations) {
return aggregations != null ? aggregations.getValue() : 0.0;
protected Optional<Double> getValue(Sum aggregations) {
return Optional.ofNullable(aggregations != null ? aggregations.getValue() : null);
}
}

View File

@ -1,6 +1,7 @@
package org.openmetadata.service.search.opensearch.dataInsightAggregator;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.AggregatedUnusedAssetsSizeAggregator;
import os.org.opensearch.search.aggregations.Aggregations;
import os.org.opensearch.search.aggregations.bucket.histogram.Histogram;
@ -34,7 +35,7 @@ public class OpenSearchAggregatedUnusedAssetsSizeAggregator
}
@Override
protected Double getValue(Sum aggregations) {
return aggregations != null ? aggregations.getValue() : 0.0;
protected Optional<Double> getValue(Sum aggregations) {
return Optional.ofNullable(aggregations != null ? aggregations.getValue() : null);
}
}

View File

@ -1,6 +1,7 @@
package org.openmetadata.service.search.opensearch.dataInsightAggregator;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.AggregatedUsedvsUnusedAssetsCountAggregator;
import os.org.opensearch.search.aggregations.Aggregations;
import os.org.opensearch.search.aggregations.bucket.histogram.Histogram;
@ -34,7 +35,7 @@ public class OpenSearchAggregatedUsedvsUnusedAssetsCountAggregator
}
@Override
protected Double getValue(Sum aggregations) {
return aggregations != null ? aggregations.getValue() : 0.0;
protected Optional<Double> getValue(Sum aggregations) {
return Optional.ofNullable(aggregations != null ? aggregations.getValue() : null);
}
}

View File

@ -1,6 +1,7 @@
package org.openmetadata.service.search.opensearch.dataInsightAggregator;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.AggregatedUsedvsUnusedAssetsSizeAggregator;
import os.org.opensearch.search.aggregations.Aggregations;
import os.org.opensearch.search.aggregations.bucket.histogram.Histogram;
@ -34,7 +35,7 @@ public class OpenSearchAggregatedUsedvsUnusedAssetsSizeAggregator
}
@Override
protected Double getValue(Sum aggregations) {
return aggregations != null ? aggregations.getValue() : 0.0;
protected Optional<Double> getValue(Sum aggregations) {
return Optional.ofNullable(aggregations != null ? aggregations.getValue() : null);
}
}

View File

@ -1,6 +1,7 @@
package org.openmetadata.service.search.opensearch.dataInsightAggregator;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.EntitiesDescriptionAggregator;
import os.org.opensearch.search.aggregations.Aggregations;
import os.org.opensearch.search.aggregations.bucket.MultiBucketsAggregation;
@ -42,7 +43,7 @@ public class OpenSearchEntitiesDescriptionAggregator
}
@Override
protected Double getValue(Sum aggregations) {
return aggregations != null ? aggregations.getValue() : 0.0;
protected Optional<Double> getValue(Sum aggregations) {
return Optional.ofNullable(aggregations != null ? aggregations.getValue() : null);
}
}

View File

@ -1,6 +1,7 @@
package org.openmetadata.service.search.opensearch.dataInsightAggregator;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.EntitiesOwnerAggregator;
import os.org.opensearch.search.aggregations.Aggregations;
import os.org.opensearch.search.aggregations.bucket.MultiBucketsAggregation;
@ -15,8 +16,8 @@ public class OpenSearchEntitiesOwnerAggregator
}
@Override
protected Double getValue(Sum key) {
return key != null ? key.getValue() : 0.0;
protected Optional<Double> getValue(Sum key) {
return Optional.ofNullable(key != null ? key.getValue() : null);
}
@Override

View File

@ -1,6 +1,7 @@
package org.openmetadata.service.search.opensearch.dataInsightAggregator;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.MostActiveUsersAggregator;
import os.org.opensearch.search.aggregations.Aggregations;
import os.org.opensearch.search.aggregations.bucket.MultiBucketsAggregation;
@ -16,13 +17,13 @@ public class OpenSearchMostActiveUsersAggregator
}
@Override
protected Double getSumValue(Sum key) {
return key != null ? key.getValue() : 0.0;
protected Optional<Double> getSumValue(Sum key) {
return Optional.ofNullable(key != null ? key.getValue() : null);
}
@Override
protected Long getMaxValue(Max key) {
return key != null ? (long) key.getValue() : 0;
protected Optional<Long> getMaxValue(Max key) {
return Optional.ofNullable(key != null ? (long) key.getValue() : null);
}
@Override

View File

@ -1,6 +1,7 @@
package org.openmetadata.service.search.opensearch.dataInsightAggregator;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.MostViewedEntitiesAggregator;
import os.org.opensearch.search.aggregations.Aggregations;
import os.org.opensearch.search.aggregations.bucket.MultiBucketsAggregation;
@ -14,8 +15,8 @@ public class OpenSearchMostViewedEntitiesAggregator
}
@Override
protected Double getValue(Sum key) {
return key != null ? key.getValue() : 0.0;
protected Optional<Double> getValue(Sum key) {
return Optional.ofNullable(key != null ? key.getValue() : null);
}
@Override

View File

@ -1,6 +1,7 @@
package org.openmetadata.service.search.opensearch.dataInsightAggregator;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.PageViewsByEntitiesAggregator;
import os.org.opensearch.search.aggregations.Aggregations;
import os.org.opensearch.search.aggregations.bucket.MultiBucketsAggregation;
@ -15,8 +16,8 @@ public class OpenSearchPageViewsByEntitiesAggregator
}
@Override
protected Double getValue(Sum key) {
return key != null ? key.getValue() : 0.0;
protected Optional<Double> getValue(Sum key) {
return Optional.ofNullable(key != null ? key.getValue() : null);
}
@Override

View File

@ -1,6 +1,7 @@
package org.openmetadata.service.search.opensearch.dataInsightAggregator;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.ServicesDescriptionAggregator;
import os.org.opensearch.search.aggregations.Aggregations;
import os.org.opensearch.search.aggregations.bucket.MultiBucketsAggregation;
@ -14,8 +15,8 @@ public class OpenSearchServicesDescriptionAggregator
}
@Override
protected Double getValue(Sum key) {
return key != null ? key.getValue() : 0.0;
protected Optional<Double> getValue(Sum key) {
return Optional.ofNullable(key != null ? key.getValue() : null);
}
@Override

View File

@ -1,6 +1,7 @@
package org.openmetadata.service.search.opensearch.dataInsightAggregator;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.ServicesOwnerAggregator;
import os.org.opensearch.search.aggregations.Aggregations;
import os.org.opensearch.search.aggregations.bucket.MultiBucketsAggregation;
@ -14,8 +15,8 @@ public class OpenSearchServicesOwnerAggregator
}
@Override
protected Double getValue(Sum key) {
return key != null ? key.getValue() : 0.0;
protected Optional<Double> getValue(Sum key) {
return Optional.ofNullable(key != null ? key.getValue() : null);
}
@Override

View File

@ -1,6 +1,7 @@
package org.openmetadata.service.search.opensearch.dataInsightAggregator;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.TotalEntitiesAggregator;
import os.org.opensearch.search.aggregations.Aggregations;
import os.org.opensearch.search.aggregations.bucket.MultiBucketsAggregation;
@ -14,8 +15,8 @@ public class OpenSearchTotalEntitiesAggregator
}
@Override
protected Double getValue(Sum key) {
return key != null ? key.getValue() : 0.0;
protected Optional<Double> getValue(Sum key) {
return Optional.ofNullable(key != null ? key.getValue() : null);
}
@Override

View File

@ -1,6 +1,7 @@
package org.openmetadata.service.search.opensearch.dataInsightAggregator;
import java.util.List;
import java.util.Optional;
import org.openmetadata.service.dataInsight.TotalEntitiesByTierAggregator;
import os.org.opensearch.search.aggregations.Aggregations;
import os.org.opensearch.search.aggregations.bucket.MultiBucketsAggregation;
@ -14,8 +15,8 @@ public class OpenSearchTotalEntitiesByTierAggregator
}
@Override
protected Double getValue(Sum key) {
return key != null ? key.getValue() : 0.0;
protected Optional<Double> getValue(Sum key) {
return Optional.ofNullable(key != null ? key.getValue() : null);
}
@Override

View File

@ -13,23 +13,38 @@
"properties": {
"threeDays": {
"description": "Data Asset Count or Size for 3 days",
"type": "number"
"anyOf": [
{"type": "number"},
{"type": "null"}
]
},
"sevenDays": {
"description": "Data Asset Count or Size for 7 days",
"type": "number"
"anyOf": [
{"type": "number"},
{"type": "null"}
]
},
"fourteenDays": {
"description": "Data Asset Count or Size for 14 days",
"type": "number"
"anyOf": [
{"type": "number"},
{"type": "null"}
]
},
"thirtyDays": {
"description": "Data Asset Count or Size for 30 days",
"type": "number"
"anyOf": [
{"type": "number"},
{"type": "null"}
]
},
"sixtyDays": {
"description": "Data Asset Count or Size for 60 days",
"type": "number"
"anyOf": [
{"type": "number"},
{"type": "null"}
]
}
},
"additionalProperties": false