Skip to content

chore: add support for DISTINCT_ARRAY aggregation operator #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ private List<Object> getArguments(
case PERCENTILE:
return MetricArguments.percentileWithSize(size.orElseThrow());
case DISTINCT_COUNT:
case DISTINCT_ARRAY:
case COUNT:
case AVG:
case SUM:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@ public BaselinedMetricAggregation percentile(int size) {
public @GraphQLNonNull BaselinedMetricAggregation distinctcount() {
return this.metricAggregationMap.get(MetricLookupMapKey.basicAggregation(DISTINCT_COUNT));
}

@Override
public @GraphQLNonNull BaselinedMetricAggregation distinctarray() {
return this.metricAggregationMap.get(MetricLookupMapKey.basicAggregation(DISTINCT_ARRAY));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.hypertrace.core.graphql.attributes.AttributeModelMetricAggregationType.AVG;
import static org.hypertrace.core.graphql.attributes.AttributeModelMetricAggregationType.COUNT;
import static org.hypertrace.core.graphql.attributes.AttributeModelMetricAggregationType.DISTINCT_ARRAY;
import static org.hypertrace.core.graphql.attributes.AttributeModelMetricAggregationType.DISTINCT_COUNT;
import static org.hypertrace.core.graphql.attributes.AttributeModelMetricAggregationType.MAX;
import static org.hypertrace.core.graphql.attributes.AttributeModelMetricAggregationType.MIN;
Expand Down Expand Up @@ -59,4 +60,9 @@ public MetricAggregation percentile(int size) {
public @GraphQLNonNull MetricAggregation distinctcount() {
return this.metricAggregationMap.get(MetricLookupMapKey.basicAggregation(DISTINCT_COUNT));
}

@Override
public @GraphQLNonNull MetricAggregation distinctarray() {
return this.metricAggregationMap.get(MetricLookupMapKey.basicAggregation(DISTINCT_ARRAY));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public Single<FunctionType> convert(AttributeModelMetricAggregationType aggregat
return Single.just(FunctionType.PERCENTILE);
case DISTINCT_COUNT:
return Single.just(FunctionType.DISTINCTCOUNT);
case DISTINCT_ARRAY:
return Single.just(FunctionType.DISTINCT_ARRAY);
default:
return Single.error(
new UnknownFormatConversionException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.hypertrace.core.graphql.attributes.AttributeModelMetricAggregationType.AVG;
import static org.hypertrace.core.graphql.attributes.AttributeModelMetricAggregationType.COUNT;
import static org.hypertrace.core.graphql.attributes.AttributeModelMetricAggregationType.DISTINCT_ARRAY;
import static org.hypertrace.core.graphql.attributes.AttributeModelMetricAggregationType.DISTINCT_COUNT;
import static org.hypertrace.core.graphql.attributes.AttributeModelMetricAggregationType.MAX;
import static org.hypertrace.core.graphql.attributes.AttributeModelMetricAggregationType.MIN;
Expand Down Expand Up @@ -63,4 +64,9 @@ public MetricBaselineAggregation percentile(int size) {
public @GraphQLNonNull MetricBaselineAggregation distinctcount() {
return this.metricAggregationMap.get(MetricLookupMapKey.basicAggregation(DISTINCT_COUNT));
}

@Override
public @GraphQLNonNull MetricBaselineAggregation distinctarray() {
return this.metricAggregationMap.get(MetricLookupMapKey.basicAggregation(DISTINCT_ARRAY));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.hypertrace.graphql.metric.schema.MetricAggregationContainer.METRIC_AGGREGATION_CONTAINER_AVGRATE_KEY;
import static org.hypertrace.graphql.metric.schema.MetricAggregationContainer.METRIC_AGGREGATION_CONTAINER_AVG_KEY;
import static org.hypertrace.graphql.metric.schema.MetricAggregationContainer.METRIC_AGGREGATION_CONTAINER_COUNT_KEY;
import static org.hypertrace.graphql.metric.schema.MetricAggregationContainer.METRIC_AGGREGATION_CONTAINER_DISTINCTARRAY_KEY;
import static org.hypertrace.graphql.metric.schema.MetricAggregationContainer.METRIC_AGGREGATION_CONTAINER_DISTINCTCOUNT_KEY;
import static org.hypertrace.graphql.metric.schema.MetricAggregationContainer.METRIC_AGGREGATION_CONTAINER_MAX_KEY;
import static org.hypertrace.graphql.metric.schema.MetricAggregationContainer.METRIC_AGGREGATION_CONTAINER_MIN_KEY;
Expand Down Expand Up @@ -126,6 +127,8 @@ private Optional<AttributeModelMetricAggregationType> getAggregationTypeForField
return Optional.of(AttributeModelMetricAggregationType.COUNT);
case METRIC_AGGREGATION_CONTAINER_DISTINCTCOUNT_KEY:
return Optional.of(AttributeModelMetricAggregationType.DISTINCT_COUNT);
case METRIC_AGGREGATION_CONTAINER_DISTINCTARRAY_KEY:
return Optional.of(AttributeModelMetricAggregationType.DISTINCT_ARRAY);
default:
return Optional.empty();
}
Expand All @@ -144,6 +147,7 @@ private List<Object> getArgumentsForAggregation(
case MIN:
case MAX:
case DISTINCT_COUNT:
case DISTINCT_ARRAY:
default:
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public interface MetricAggregationContainer {
String METRIC_AGGREGATION_CONTAINER_PERCENTILE_KEY = "percentile";
String METRIC_AGGREGATION_CONTAINER_COUNT_KEY = "count";
String METRIC_AGGREGATION_CONTAINER_DISTINCTCOUNT_KEY = "distinctcount";
String METRIC_AGGREGATION_CONTAINER_DISTINCTARRAY_KEY = "distinctarray";

@GraphQLField
@GraphQLNonNull
Expand Down Expand Up @@ -48,6 +49,11 @@ public interface MetricAggregationContainer {
@GraphQLName(METRIC_AGGREGATION_CONTAINER_DISTINCTCOUNT_KEY)
MetricAggregation distinctcount();

@GraphQLField
@GraphQLNonNull
@GraphQLName(METRIC_AGGREGATION_CONTAINER_DISTINCTARRAY_KEY)
MetricAggregation distinctarray();

@GraphQLField
@GraphQLNonNull
@GraphQLName(METRIC_AGGREGATION_CONTAINER_AVGRATE_KEY)
Expand Down