Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

Commit

Permalink
chore: rename DISTINCT function type to DISTINCT_ARRAY (#146)
Browse files Browse the repository at this point in the history
* throw error on trying to hit query service with DISTINCT_ARRAY function type

* fix typo

* address review comments
  • Loading branch information
SrikarMannepalli authored Sep 19, 2022
1 parent 7b9d3b7 commit 7e0d405
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ enum FunctionType {
// Have thought of introducing a parameter for estimate later.
PERCENTILE = 8;
DISTINCTCOUNT = 9;
DISTINCT = 10;
DISTINCT_ARRAY = 10; //This is currently supported only for EDS
}

enum ValueType {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.hypertrace.gateway.service.common.converters;

import static java.lang.String.format;
import static org.hypertrace.gateway.service.v1.common.FunctionType.DISTINCT_ARRAY;

import com.google.common.base.Strings;
import java.time.Duration;
import java.util.List;
Expand Down Expand Up @@ -337,8 +340,7 @@ public static Expression.Builder convertToQueryExpression(
case HEALTH:
default:
throw new IllegalArgumentException(
String.format(
"Cannot convert %s expression to query expression.", expression.getValueCase()));
format("Cannot convert %s expression to query expression.", expression.getValueCase()));
}
}

Expand Down Expand Up @@ -414,6 +416,11 @@ private static Function convertToQueryFunction(
columns.forEach(e -> builder.addArguments(convertToQueryExpression(e)));
break;
}
case DISTINCT_ARRAY:
throw new IllegalArgumentException(
format(
"Aggregation by the function type: %s is not supported by query service currently",
function.getFunction().name()));
default:
{
builder.setFunctionName(function.getFunction().name()).setAlias(function.getAlias());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ public void testFunctionExpressionConversion() {
qe, QueryAndGatewayDtoConverter.convertToQueryExpression(ge).build()));
}

@Test
public void testDistinctArrayFunctionExpressionConversionFailure() {
Expression gatewayExprArgument =
QueryExpressionUtil.buildAttributeExpression("API.apiId").build();
Expression gatewayExpr =
Expression.newBuilder()
.setFunction(
FunctionExpression.newBuilder()
.setFunction(FunctionType.DISTINCT_ARRAY)
.addArguments(gatewayExprArgument)
.build())
.build();
Assertions.assertThrows(
IllegalArgumentException.class,
() -> QueryAndGatewayDtoConverter.convertToQueryExpression(gatewayExpr));
}

@Test
public void testExpressionWithOrderBy() {
getOrderByExpressionMap()
Expand Down

0 comments on commit 7e0d405

Please sign in to comment.