From da7e1ecd12e1955218af0d4b81ca91d79108d31e Mon Sep 17 00:00:00 2001 From: saxenakshitiz Date: Wed, 6 Dec 2023 17:45:16 +0530 Subject: [PATCH 1/9] chore: convert 'null' string array value to list with 'null' value --- .../converters/StringToAttributeKindConverter.java | 9 +++++++++ .../converter/StringToAttributeKindConverterTest.java | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/StringToAttributeKindConverter.java b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/StringToAttributeKindConverter.java index 46c217cb..ef27f859 100644 --- a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/StringToAttributeKindConverter.java +++ b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/StringToAttributeKindConverter.java @@ -24,6 +24,8 @@ public class StringToAttributeKindConverter extends ToAttributeKindConverter> LIST_TYPE_REFERENCE = new TypeReference<>() {}; public static final StringToAttributeKindConverter INSTANCE = new StringToAttributeKindConverter(); + private static final String ARRAY_NULL_VALUE = "null"; + private static final List LIST_NULL_VALUE = List.of("null"); private final ObjectMapper objectMapper = new ObjectMapper(); private StringToAttributeKindConverter() {} @@ -92,6 +94,13 @@ private List convertToArray(String jsonString) { return List.of(); } + // handle special case when "null" string is returned as string array value(default value + // scenario) + // "null" is still a valid value, and should be converted to list with "null" value + if (ARRAY_NULL_VALUE.equals(jsonString)) { + return LIST_NULL_VALUE; + } + // Check if the string is already in a list format. try { return Optional.ofNullable(objectMapper.readValue(jsonString, LIST_TYPE_REFERENCE)) diff --git a/gateway-service-impl/src/test/java/org/hypertrace/gateway/service/common/converter/StringToAttributeKindConverterTest.java b/gateway-service-impl/src/test/java/org/hypertrace/gateway/service/common/converter/StringToAttributeKindConverterTest.java index 835f28b3..376a609e 100644 --- a/gateway-service-impl/src/test/java/org/hypertrace/gateway/service/common/converter/StringToAttributeKindConverterTest.java +++ b/gateway-service-impl/src/test/java/org/hypertrace/gateway/service/common/converter/StringToAttributeKindConverterTest.java @@ -56,10 +56,10 @@ public void testStringToAttributeKindConverterJsonArrayStr() { } @Test - public void test_nullStringToArrayReturnsEmptyList() { + public void test_nullStringToArrayReturnsListWithNull() { StringToAttributeKindConverter converter = StringToAttributeKindConverter.INSTANCE; assertEquals( - List.of(), + List.of("null"), converter .doConvert("null", AttributeKind.TYPE_STRING_ARRAY, Value.newBuilder()) .getStringArrayList()); From 5336c3b870afe00c9b6196c82b069f3e06cef729 Mon Sep 17 00:00:00 2001 From: saxenakshitiz Date: Wed, 6 Dec 2023 17:48:50 +0530 Subject: [PATCH 2/9] minor changes --- .../converters/StringToAttributeKindConverter.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/StringToAttributeKindConverter.java b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/StringToAttributeKindConverter.java index ef27f859..856b6456 100644 --- a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/StringToAttributeKindConverter.java +++ b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/StringToAttributeKindConverter.java @@ -24,8 +24,8 @@ public class StringToAttributeKindConverter extends ToAttributeKindConverter> LIST_TYPE_REFERENCE = new TypeReference<>() {}; public static final StringToAttributeKindConverter INSTANCE = new StringToAttributeKindConverter(); - private static final String ARRAY_NULL_VALUE = "null"; - private static final List LIST_NULL_VALUE = List.of("null"); + private static final String STRING_ARRAY_NULL_VALUE = "null"; + private static final List LIST_WITH_NULL_VALUE = List.of("null"); private final ObjectMapper objectMapper = new ObjectMapper(); private StringToAttributeKindConverter() {} @@ -95,10 +95,9 @@ private List convertToArray(String jsonString) { } // handle special case when "null" string is returned as string array value(default value - // scenario) - // "null" is still a valid value, and should be converted to list with "null" value - if (ARRAY_NULL_VALUE.equals(jsonString)) { - return LIST_NULL_VALUE; + // scenario). "null" is still a valid value, and should be converted to list with "null" value + if (STRING_ARRAY_NULL_VALUE.equals(jsonString)) { + return LIST_WITH_NULL_VALUE; } // Check if the string is already in a list format. From 61750eccce16c7bf7912ec8e62e27a51440a8395 Mon Sep 17 00:00:00 2001 From: saxenakshitiz Date: Wed, 6 Dec 2023 18:19:24 +0530 Subject: [PATCH 3/9] fix dependency check --- gateway-service-impl/build.gradle.kts | 4 ++-- .../StringToAttributeKindConverter.java | 4 ++-- owasp-suppressions.xml | 19 ++++++++++--------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/gateway-service-impl/build.gradle.kts b/gateway-service-impl/build.gradle.kts index 2caa403d..6b07a7d0 100644 --- a/gateway-service-impl/build.gradle.kts +++ b/gateway-service-impl/build.gradle.kts @@ -33,8 +33,8 @@ dependencies { implementation("com.google.guava:guava:32.1.2-jre") implementation("com.google.inject:guice:5.0.1") - implementation("com.fasterxml.jackson.core:jackson-annotations:2.15.2") - implementation("com.fasterxml.jackson.core:jackson-databind:2.15.2") + implementation("com.fasterxml.jackson.core:jackson-annotations:2.16.0") + implementation("com.fasterxml.jackson.core:jackson-databind:2.16.0") testImplementation("org.junit.jupiter:junit-jupiter:5.8.2") testImplementation("org.mockito:mockito-junit-jupiter:5.4.0") diff --git a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/StringToAttributeKindConverter.java b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/StringToAttributeKindConverter.java index 856b6456..52f8d207 100644 --- a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/StringToAttributeKindConverter.java +++ b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/StringToAttributeKindConverter.java @@ -25,7 +25,7 @@ public class StringToAttributeKindConverter extends ToAttributeKindConverter LIST_WITH_NULL_VALUE = List.of("null"); + private static final List LIST_WITH_NULL_STRING_VALUE = List.of("null"); private final ObjectMapper objectMapper = new ObjectMapper(); private StringToAttributeKindConverter() {} @@ -97,7 +97,7 @@ private List convertToArray(String jsonString) { // handle special case when "null" string is returned as string array value(default value // scenario). "null" is still a valid value, and should be converted to list with "null" value if (STRING_ARRAY_NULL_VALUE.equals(jsonString)) { - return LIST_WITH_NULL_VALUE; + return LIST_WITH_NULL_STRING_VALUE; } // Check if the string is already in a list format. diff --git a/owasp-suppressions.xml b/owasp-suppressions.xml index d3486420..74e475e7 100644 --- a/owasp-suppressions.xml +++ b/owasp-suppressions.xml @@ -9,15 +9,7 @@ cpe:/a:utils_project:utils cpe:/a:service_project:service - - - ^pkg:maven/com\.fasterxml\.jackson\.core/jackson\-databind@.*$ - CVE-2023-35116 - - + ^pkg:maven/io\.netty/netty.*@.*$ CVE-2023-4586 + + + ^pkg:maven/io\.grpc/grpc\-.*@.*$ + CVE-2023-44487 + From 8cb1ea6dfe14c53217541391e4ec4e11529caf67 Mon Sep 17 00:00:00 2001 From: saxenakshitiz Date: Thu, 7 Dec 2023 01:26:52 +0530 Subject: [PATCH 4/9] address review comments --- .../converters/StringToAttributeKindConverter.java | 8 -------- .../TimeAggregationsWithGroupByRequestHandler.java | 11 ++++++++++- .../converter/StringToAttributeKindConverterTest.java | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/StringToAttributeKindConverter.java b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/StringToAttributeKindConverter.java index 52f8d207..46c217cb 100644 --- a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/StringToAttributeKindConverter.java +++ b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/StringToAttributeKindConverter.java @@ -24,8 +24,6 @@ public class StringToAttributeKindConverter extends ToAttributeKindConverter> LIST_TYPE_REFERENCE = new TypeReference<>() {}; public static final StringToAttributeKindConverter INSTANCE = new StringToAttributeKindConverter(); - private static final String STRING_ARRAY_NULL_VALUE = "null"; - private static final List LIST_WITH_NULL_STRING_VALUE = List.of("null"); private final ObjectMapper objectMapper = new ObjectMapper(); private StringToAttributeKindConverter() {} @@ -94,12 +92,6 @@ private List convertToArray(String jsonString) { return List.of(); } - // handle special case when "null" string is returned as string array value(default value - // scenario). "null" is still a valid value, and should be converted to list with "null" value - if (STRING_ARRAY_NULL_VALUE.equals(jsonString)) { - return LIST_WITH_NULL_STRING_VALUE; - } - // Check if the string is already in a list format. try { return Optional.ofNullable(objectMapper.readValue(jsonString, LIST_TYPE_REFERENCE)) diff --git a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TimeAggregationsWithGroupByRequestHandler.java b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TimeAggregationsWithGroupByRequestHandler.java index 5690e195..57d36f18 100644 --- a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TimeAggregationsWithGroupByRequestHandler.java +++ b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TimeAggregationsWithGroupByRequestHandler.java @@ -30,6 +30,8 @@ public class TimeAggregationsWithGroupByRequestHandler implements IRequestHandle private static final Logger LOG = LoggerFactory.getLogger(TimeAggregationsWithGroupByRequestHandler.class); + private static final List LIST_WITH_NULL_STRING = List.of("null"); + private final AttributeMetadataProvider attributeMetadataProvider; private final RequestHandler normalRequestHandler; private final TimeAggregationsRequestHandler timeAggregationsRequestHandler; @@ -228,7 +230,14 @@ private void buildInClauseFilterValue(Value value, Value.Builder valueBuilder) { valueBuilder.addStringArray(value.getString()); break; case STRING_ARRAY: - valueBuilder.addAllStringArray(value.getStringArrayList()); + // Handle special case when "null" string is returned as string array value(default value + // scenario). This will be converted to empty list in value converter. In such a case use + // list with "null" value + if (value.getStringArrayList().isEmpty()) { + valueBuilder.addAllStringArray(LIST_WITH_NULL_STRING); + } else { + valueBuilder.addAllStringArray(value.getStringArrayList()); + } break; case LONG: valueBuilder.addLongArray(value.getLong()); diff --git a/gateway-service-impl/src/test/java/org/hypertrace/gateway/service/common/converter/StringToAttributeKindConverterTest.java b/gateway-service-impl/src/test/java/org/hypertrace/gateway/service/common/converter/StringToAttributeKindConverterTest.java index 376a609e..835f28b3 100644 --- a/gateway-service-impl/src/test/java/org/hypertrace/gateway/service/common/converter/StringToAttributeKindConverterTest.java +++ b/gateway-service-impl/src/test/java/org/hypertrace/gateway/service/common/converter/StringToAttributeKindConverterTest.java @@ -56,10 +56,10 @@ public void testStringToAttributeKindConverterJsonArrayStr() { } @Test - public void test_nullStringToArrayReturnsListWithNull() { + public void test_nullStringToArrayReturnsEmptyList() { StringToAttributeKindConverter converter = StringToAttributeKindConverter.INSTANCE; assertEquals( - List.of("null"), + List.of(), converter .doConvert("null", AttributeKind.TYPE_STRING_ARRAY, Value.newBuilder()) .getStringArrayList()); From 44bf5bc0366dc7fc16d0cb5d363b34bd32d6478d Mon Sep 17 00:00:00 2001 From: saxenakshitiz Date: Thu, 7 Dec 2023 14:44:08 +0530 Subject: [PATCH 5/9] added tests and handled others case --- .../explore/TheRestGroupRequestHandler.java | 14 +- ...AggregationsWithGroupByRequestHandler.java | 31 + .../test/resources/attributes/attributes.json | 11 + ...it-and-the-rest-with-null-value-group.json | 100 ++++ ...mit-with-null-and-nonnull-value-group.json | 93 +++ ...ith-group-limit-with-null-value-group.json | 48 ++ ...it-and-the-rest-with-null-value-group.json | 529 ++++++++++++++++++ ...mit-with-null-and-nonnull-value-group.json | 372 ++++++++++++ ...ith-group-limit-with-null-value-group.json | 322 +++++++++++ ...it-and-the-rest-with-null-value-group.json | 39 ++ ...mit-with-null-and-nonnull-value-group.json | 40 ++ ...ith-group-limit-with-null-value-group.json | 40 ++ 12 files changed, 1638 insertions(+), 1 deletion(-) create mode 100644 gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json create mode 100644 gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json create mode 100644 gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json create mode 100644 gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json create mode 100644 gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json create mode 100644 gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json create mode 100644 gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json create mode 100644 gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json create mode 100644 gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json diff --git a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TheRestGroupRequestHandler.java b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TheRestGroupRequestHandler.java index e410e2d8..5d393158 100644 --- a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TheRestGroupRequestHandler.java +++ b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TheRestGroupRequestHandler.java @@ -6,6 +6,7 @@ import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; +import java.util.stream.Stream; import org.hypertrace.gateway.service.common.util.ExpressionReader; import org.hypertrace.gateway.service.v1.common.Expression; import org.hypertrace.gateway.service.v1.common.Filter; @@ -224,10 +225,21 @@ private Set getExcludedValues( String resultName, ExploreResponse.Builder originalResponse) { return originalResponse.getRowBuilderList().stream() .map(rowBuilder -> rowBuilder.getColumnsMap().get(resultName)) - .map(Value::getString) + .flatMap(this::getStringValues) .collect(ImmutableSet.toImmutableSet()); } + private Stream getStringValues(Value value) { + switch (value.getValueType()) { + case STRING: + return Stream.of(value.getString()); + case STRING_ARRAY: + return value.getStringArrayList().stream(); + default: + return Stream.of(); + } + } + private Filter.Builder createExcludedChildFilter( Expression groupBySelectionExpression, Set excludedValues) { return Filter.newBuilder() diff --git a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TimeAggregationsWithGroupByRequestHandler.java b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TimeAggregationsWithGroupByRequestHandler.java index 57d36f18..45d49e50 100644 --- a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TimeAggregationsWithGroupByRequestHandler.java +++ b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TimeAggregationsWithGroupByRequestHandler.java @@ -80,6 +80,8 @@ public ExploreResponse.Builder handleRequest( timeAggregationsRequestHandler.handleRequest( timeAggregationsRequestContext, timeAggregationsRequest); + updateExploreResponse(timeAggregationsResponse); + // 3. If includeRestGroup is set, and we have not reached limit // then invoke TheRestGroupRequestHandler if (request.getIncludeRestGroup() @@ -304,4 +306,33 @@ private Map remapAttributeMetadataByResultName( .collect(Collectors.toUnmodifiableList()), attributeMetadataByIdMap); } + + private void updateExploreResponse(ExploreResponse.Builder timeAggregationsResponse) { + List updatedRows = + timeAggregationsResponse.getRowList().stream() + .map( + row -> { + Row.Builder builder = row.toBuilder(); + builder + .getColumnsMap() + .forEach( + (k, v) -> { + // if value is of tye string array and value list is empty, then need to + // add "null" as value list + if (v.getValueType().equals(ValueType.STRING_ARRAY) + && v.getStringArrayList().isEmpty()) { + builder.putColumns( + k, + Value.newBuilder() + .setValueType(ValueType.STRING_ARRAY) + .addAllStringArray(LIST_WITH_NULL_STRING) + .build()); + } + }); + return builder.build(); + }) + .collect(Collectors.toUnmodifiableList()); + timeAggregationsResponse.clearRow(); + timeAggregationsResponse.addAllRow(updatedRows); + } } diff --git a/gateway-service-impl/src/test/resources/attributes/attributes.json b/gateway-service-impl/src/test/resources/attributes/attributes.json index 30d873c1..9e3cb0e8 100644 --- a/gateway-service-impl/src/test/resources/attributes/attributes.json +++ b/gateway-service-impl/src/test/resources/attributes/attributes.json @@ -945,6 +945,17 @@ "QS" ] }, + { + "fqn": "Service.userRoles", + "valueKind": "TYPE_STRING_ARRAY", + "key": "userRoles", + "displayName": "Service User Roles", + "scopeString": "SERVICE", + "type": "ATTRIBUTE", + "sources": [ + "QS" + ] + }, { "fqn": "Service.start_time_millis", "valueKind": "TYPE_INT64", diff --git a/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json b/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json new file mode 100644 index 00000000..96b04c09 --- /dev/null +++ b/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json @@ -0,0 +1,100 @@ +{ + "row": [ + { + "columns": { + "INTERVAL_START_TIME": { + "valueType": "LONG", + "long": "1615593600000" + }, + "SERVICE.userRoles": { + "valueType": "STRING_ARRAY", + "string_array": ["null"] + }, + "SUM_SERVICE.numCalls_[]": { + "valueType": "LONG", + "long": "1616" + } + } + }, + { + "columns": { + "INTERVAL_START_TIME": { + "valueType": "LONG", + "long": "1615593600000" + }, + "SERVICE.userRoles": { + "valueType": "STRING_ARRAY", + "string_array": ["nginx-traceshop"] + }, + "SUM_SERVICE.numCalls_[]": { + "valueType": "LONG", + "long": "1989" + } + } + }, + { + "columns": { + "INTERVAL_START_TIME": { + "valueType": "LONG", + "long": "1615597200000" + }, + "SERVICE.userRoles": { + "valueType": "STRING_ARRAY", + "string_array": ["null"] + }, + "SUM_SERVICE.numCalls_[]": { + "valueType": "LONG", + "long": "2525" + } + } + }, + { + "columns": { + "INTERVAL_START_TIME": { + "valueType": "LONG", + "long": "1615597200000" + }, + "SERVICE.userRoles": { + "valueType": "STRING_ARRAY", + "string_array": ["nginx-traceshop"] + }, + "SUM_SERVICE.numCalls_[]": { + "valueType": "LONG", + "long": "1977" + } + } + }, + { + "columns": { + "INTERVAL_START_TIME": { + "valueType": "LONG", + "long": "1615593600000" + }, + "SUM_SERVICE.numCalls_[]": { + "valueType": "LONG", + "long": "27485" + }, + "SERVICE.userRoles": { + "valueType": "STRING", + "string": "__Other" + } + } + }, + { + "columns": { + "INTERVAL_START_TIME": { + "valueType": "LONG", + "long": "1615597200000" + }, + "SUM_SERVICE.numCalls_[]": { + "valueType": "LONG", + "long": "27192" + }, + "SERVICE.userRoles": { + "valueType": "STRING", + "string": "__Other" + } + } + } + ] +} \ No newline at end of file diff --git a/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json b/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json new file mode 100644 index 00000000..395a4f30 --- /dev/null +++ b/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json @@ -0,0 +1,93 @@ +{ + "row": [{ + "columns": { + "INTERVAL_START_TIME": { + "valueType": "LONG", + "long": "1615593600000" + }, + "SERVICE.userRoles": { + "valueType": "STRING_ARRAY", + "string_array": ["null"] + }, + "SUM_SERVICE.numCalls_[]": { + "valueType": "LONG", + "long": "1616" + } + } + }, { + "columns": { + "INTERVAL_START_TIME": { + "valueType": "LONG", + "long": "1615593600000" + }, + "SERVICE.userRoles": { + "valueType": "STRING_ARRAY", + "string_array": ["nginx-traceshop"] + }, + "SUM_SERVICE.numCalls_[]": { + "valueType": "LONG", + "long": "1989" + } + } + }, { + "columns": { + "INTERVAL_START_TIME": { + "valueType": "LONG", + "long": "1615597200000" + }, + "SERVICE.userRoles": { + "valueType": "STRING_ARRAY", + "string_array": ["null"] + }, + "SUM_SERVICE.numCalls_[]": { + "valueType": "LONG", + "long": "2525" + } + } + }, { + "columns": { + "INTERVAL_START_TIME": { + "valueType": "LONG", + "long": "1615597200000" + }, + "SERVICE.userRoles": { + "valueType": "STRING_ARRAY", + "string_array": ["nginx-traceshop"] + }, + "SUM_SERVICE.numCalls_[]": { + "valueType": "LONG", + "long": "1977" + } + } + }, { + "columns": { + "INTERVAL_START_TIME": { + "valueType": "LONG", + "long": "1615600800000" + }, + "SERVICE.userRoles": { + "valueType": "STRING_ARRAY", + "string_array": ["nginx-traceshop"] + }, + "SUM_SERVICE.numCalls_[]": { + "valueType": "LONG", + "long": "1965" + } + } + }, { + "columns": { + "INTERVAL_START_TIME": { + "valueType": "LONG", + "long": "1615600800000" + }, + "SERVICE.userRoles": { + "valueType": "STRING_ARRAY", + "string_array": ["null"] + }, + "SUM_SERVICE.numCalls_[]": { + "valueType": "LONG", + "long": "2323" + } + } + }] +} \ No newline at end of file diff --git a/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json b/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json new file mode 100644 index 00000000..bde4b93e --- /dev/null +++ b/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json @@ -0,0 +1,48 @@ +{ + "row": [{ + "columns": { + "INTERVAL_START_TIME": { + "valueType": "LONG", + "long": "1615593600000" + }, + "SERVICE.userRoles": { + "valueType": "STRING_ARRAY", + "string_array": ["null"] + }, + "SUM_SERVICE.numCalls_[]": { + "valueType": "LONG", + "long": "1616" + } + } + }, { + "columns": { + "INTERVAL_START_TIME": { + "valueType": "LONG", + "long": "1615597200000" + }, + "SERVICE.userRoles": { + "valueType": "STRING_ARRAY", + "string_array": ["null"] + }, + "SUM_SERVICE.numCalls_[]": { + "valueType": "LONG", + "long": "2525" + } + } + }, { + "columns": { + "INTERVAL_START_TIME": { + "valueType": "LONG", + "long": "1615600800000" + }, + "SERVICE.userRoles": { + "valueType": "STRING_ARRAY", + "string_array": ["null"] + }, + "SUM_SERVICE.numCalls_[]": { + "valueType": "LONG", + "long": "2323" + } + } + }] +} \ No newline at end of file diff --git a/gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json b/gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json new file mode 100644 index 00000000..66332df5 --- /dev/null +++ b/gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json @@ -0,0 +1,529 @@ +[ + { + "request": { + "filter": { + "childFilter": [ + { + "lhs": { + "attributeExpression": { + "attributeId": "SERVICE.startTime" + } + }, + "operator": "GE", + "rhs": { + "literal": { + "value": { + "valueType": "LONG", + "long": "1615593600000" + } + } + } + }, + { + "lhs": { + "attributeExpression": { + "attributeId": "SERVICE.startTime" + } + }, + "operator": "LT", + "rhs": { + "literal": { + "value": { + "valueType": "LONG", + "long": "1615844349000" + } + } + } + } + ] + }, + "selection": [ + { + "function": { + "functionName": "SUM", + "arguments": [ + { + "attributeExpression": { + "attributeId": "SERVICE.numCalls" + } + } + ], + "alias": "SUM_SERVICE.numCalls_[]" + } + }, + { + "attributeExpression": { + "attributeId": "SERVICE.userRoles", + "alias": "SERVICE.userRoles" + } + } + ], + "groupBy": [ + { + "attributeExpression": { + "attributeId": "SERVICE.userRoles", + "alias": "SERVICE.userRoles" + } + } + ], + "limit": 2 + }, + "response": { + "isLastChunk": true, + "resultSetMetadata": { + "columnMetadata": [ + { + "columnName": "SERVICE.userRoles" + }, + { + "columnName": "SUM_SERVICE.numCalls_[]" + } + ] + }, + "row": [ + { + "column": [ + { + "string": "null" + }, + { + "string": "136098.0" + } + ] + }, + { + "column": [ + { + "string": "nginx-traceshop" + }, + { + "string": "136269.0" + } + ] + } + ] + } + }, + { + "request": { + "filter": { + "childFilter": [ + { + "childFilter": [ + { + "lhs": { + "attributeExpression": { + "attributeId": "SERVICE.startTime" + } + }, + "operator": "GE", + "rhs": { + "literal": { + "value": { + "valueType": "LONG", + "long": "1615593600000" + } + } + } + }, + { + "lhs": { + "attributeExpression": { + "attributeId": "SERVICE.startTime" + } + }, + "operator": "LT", + "rhs": { + "literal": { + "value": { + "valueType": "LONG", + "long": "1615842000000" + } + } + } + } + ] + }, + { + "childFilter": [ + { + "lhs": { + "attributeExpression": { + "attributeId": "SERVICE.userRoles", + "alias": "SERVICE.userRoles" + } + }, + "operator": "IN", + "rhs": { + "literal": { + "value": { + "valueType": "STRING_ARRAY", + "stringArray": [ + "null", + "nginx-traceshop" + ] + } + } + } + } + ] + } + ] + }, + "selection": [ + { + "function": { + "functionName": "SUM", + "arguments": [ + { + "attributeExpression": { + "attributeId": "SERVICE.numCalls" + } + } + ], + "alias": "SUM_SERVICE.numCalls_[]" + } + }, + { + "attributeExpression": { + "attributeId": "SERVICE.userRoles", + "alias": "SERVICE.userRoles" + } + } + ], + "groupBy": [ + { + "function": { + "functionName": "dateTimeConvert", + "arguments": [ + { + "attributeExpression": { + "attributeId": "SERVICE.startTime" + } + }, + { + "literal": { + "value": { + "string": "1:MILLISECONDS:EPOCH" + } + } + }, + { + "literal": { + "value": { + "string": "1:MILLISECONDS:EPOCH" + } + } + }, + { + "literal": { + "value": { + "string": "3600:SECONDS" + } + } + } + ] + } + }, + { + "attributeExpression": { + "attributeId": "SERVICE.userRoles", + "alias": "SERVICE.userRoles" + } + } + ], + "orderBy": [ + { + "expression": { + "function": { + "functionName": "dateTimeConvert", + "arguments": [ + { + "attributeExpression": { + "attributeId": "SERVICE.startTime" + } + }, + { + "literal": { + "value": { + "string": "1:MILLISECONDS:EPOCH" + } + } + }, + { + "literal": { + "value": { + "string": "1:MILLISECONDS:EPOCH" + } + } + }, + { + "literal": { + "value": { + "string": "3600:SECONDS" + } + } + } + ] + } + } + } + ], + "limit": 6 + }, + "response": { + "isLastChunk": true, + "resultSetMetadata": { + "columnMetadata": [ + { + "columnName": "dateTimeConvert" + }, + { + "columnName": "SERVICE.userRoles" + }, + { + "columnName": "SUM_SERVICE.numCalls_[]" + } + ] + }, + "row": [ + { + "column": [ + { + "string": "1615593600000" + }, + { + "string": "null" + }, + { + "string": "1616.0" + } + ] + }, + { + "column": [ + { + "string": "1615593600000" + }, + { + "string": "nginx-traceshop" + }, + { + "string": "1989.0" + } + ] + }, + { + "column": [ + { + "string": "1615597200000" + }, + { + "string": "null" + }, + { + "string": "2525.0" + } + ] + }, + { + "column": [ + { + "string": "1615597200000" + }, + { + "string": "nginx-traceshop" + }, + { + "string": "1977.0" + } + ] + } + ] + } + }, + { + "request": { + "filter": { + "childFilter": [ + { + "childFilter": [ + { + "lhs": { + "attributeExpression": { + "attributeId": "SERVICE.startTime" + } + }, + "operator": "GE", + "rhs": { + "literal": { + "value": { + "valueType": "LONG", + "long": "1615593600000" + } + } + } + }, + { + "lhs": { + "attributeExpression": { + "attributeId": "SERVICE.startTime" + } + }, + "operator": "LT", + "rhs": { + "literal": { + "value": { + "valueType": "LONG", + "long": "1615842000000" + } + } + } + } + ] + }, + { + "childFilter": [ + { + "lhs": { + "attributeExpression": { + "attributeId": "SERVICE.userRoles", + "alias": "SERVICE.userRoles" + } + }, + "operator": "NOT_IN", + "rhs": { + "literal": { + "value": { + "valueType": "STRING_ARRAY", + "stringArray": [ + "null", + "nginx-traceshop" + ] + } + } + } + } + ] + } + ] + }, + "selection": [ + { + "function": { + "functionName": "SUM", + "arguments": [ + { + "attributeExpression": { + "attributeId": "SERVICE.numCalls" + } + } + ], + "alias": "SUM_SERVICE.numCalls_[]" + } + } + ], + "groupBy": [ + { + "function": { + "functionName": "dateTimeConvert", + "arguments": [ + { + "attributeExpression": { + "attributeId": "SERVICE.startTime" + } + }, + { + "literal": { + "value": { + "string": "1:MILLISECONDS:EPOCH" + } + } + }, + { + "literal": { + "value": { + "string": "1:MILLISECONDS:EPOCH" + } + } + }, + { + "literal": { + "value": { + "string": "3600:SECONDS" + } + } + } + ] + } + } + ], + "orderBy": [{ + "expression": { + "function": { + "functionName": "dateTimeConvert", + "arguments": [{ + "attributeExpression": { + "attributeId": "SERVICE.startTime" + } + }, { + "literal": { + "value": { + "string": "1:MILLISECONDS:EPOCH" + } + } + }, { + "literal": { + "value": { + "string": "1:MILLISECONDS:EPOCH" + } + } + }, { + "literal": { + "value": { + "string": "3600:SECONDS" + } + } + }] + } + } + }], + "limit": 2 + }, + "response": { + "isLastChunk": true, + "resultSetMetadata": { + "columnMetadata": [ + { + "columnName": "dateTimeConvert" + }, + { + "columnName": "SUM_SERVICE.numCalls_[]" + } + ] + }, + "row": [ + { + "column": [ + { + "string": "1615593600000" + }, + { + "string": "27485.0" + } + ] + }, + { + "column": [ + { + "string": "1615597200000" + }, + { + "string": "27192.0" + } + ] + } + ] + } + } +] \ No newline at end of file diff --git a/gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json b/gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json new file mode 100644 index 00000000..f7ce28ed --- /dev/null +++ b/gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json @@ -0,0 +1,372 @@ +[ + { + "request": { + "filter": { + "childFilter": [ + { + "lhs": { + "attributeExpression": { + "attributeId": "SERVICE.startTime" + } + }, + "operator": "GE", + "rhs": { + "literal": { + "value": { + "valueType": "LONG", + "long": "1615593600000" + } + } + } + }, + { + "lhs": { + "attributeExpression": { + "attributeId": "SERVICE.startTime" + } + }, + "operator": "LT", + "rhs": { + "literal": { + "value": { + "valueType": "LONG", + "long": "1615844349000" + } + } + } + } + ] + }, + "selection": [ + { + "function": { + "functionName": "SUM", + "arguments": [ + { + "attributeExpression": { + "attributeId": "SERVICE.numCalls" + } + } + ], + "alias": "SUM_SERVICE.numCalls_[]" + } + }, + { + "attributeExpression": { + "attributeId": "SERVICE.userRoles", + "alias": "SERVICE.userRoles" + } + } + ], + "groupBy": [ + { + "attributeExpression": { + "attributeId": "SERVICE.userRoles", + "alias": "SERVICE.userRoles" + } + } + ], + "limit": 2 + }, + "response": { + "isLastChunk": true, + "resultSetMetadata": { + "columnMetadata": [ + { + "columnName": "SERVICE.userRoles" + }, + { + "columnName": "SUM_SERVICE.numCalls_[]" + } + ] + }, + "row": [ + { + "column": [ + { + "string": "null" + }, + { + "string": "136098.0" + } + ] + }, + { + "column": [ + { + "string": "nginx-traceshop" + }, + { + "string": "136269.0" + } + ] + } + ] + } + }, + { + "request": { + "filter": { + "childFilter": [ + { + "childFilter": [ + { + "lhs": { + "attributeExpression": { + "attributeId": "SERVICE.startTime" + } + }, + "operator": "GE", + "rhs": { + "literal": { + "value": { + "valueType": "LONG", + "long": "1615593600000" + } + } + } + }, + { + "lhs": { + "attributeExpression": { + "attributeId": "SERVICE.startTime" + } + }, + "operator": "LT", + "rhs": { + "literal": { + "value": { + "valueType": "LONG", + "long": "1615842000000" + } + } + } + } + ] + }, + { + "childFilter": [ + { + "lhs": { + "attributeExpression": { + "attributeId": "SERVICE.userRoles", + "alias": "SERVICE.userRoles" + } + }, + "operator": "IN", + "rhs": { + "literal": { + "value": { + "valueType": "STRING_ARRAY", + "stringArray": [ + "null", + "nginx-traceshop" + ] + } + } + } + } + ] + } + ] + }, + "selection": [ + { + "function": { + "functionName": "SUM", + "arguments": [ + { + "attributeExpression": { + "attributeId": "SERVICE.numCalls" + } + } + ], + "alias": "SUM_SERVICE.numCalls_[]" + } + }, + { + "attributeExpression": { + "attributeId": "SERVICE.userRoles", + "alias": "SERVICE.userRoles" + } + } + ], + "groupBy": [ + { + "function": { + "functionName": "dateTimeConvert", + "arguments": [ + { + "attributeExpression": { + "attributeId": "SERVICE.startTime" + } + }, + { + "literal": { + "value": { + "string": "1:MILLISECONDS:EPOCH" + } + } + }, + { + "literal": { + "value": { + "string": "1:MILLISECONDS:EPOCH" + } + } + }, + { + "literal": { + "value": { + "string": "3600:SECONDS" + } + } + } + ] + } + }, + { + "attributeExpression": { + "attributeId": "SERVICE.userRoles", + "alias": "SERVICE.userRoles" + } + } + ], + "orderBy": [ + { + "expression": { + "function": { + "functionName": "dateTimeConvert", + "arguments": [ + { + "attributeExpression": { + "attributeId": "SERVICE.startTime" + } + }, + { + "literal": { + "value": { + "string": "1:MILLISECONDS:EPOCH" + } + } + }, + { + "literal": { + "value": { + "string": "1:MILLISECONDS:EPOCH" + } + } + }, + { + "literal": { + "value": { + "string": "3600:SECONDS" + } + } + } + ] + } + }, + "order": "DESC" + } + ], + "limit": 6 + }, + "response": { + "isLastChunk": true, + "resultSetMetadata": { + "columnMetadata": [ + { + "columnName": "dateTimeConvert" + }, + { + "columnName": "SERVICE.userRoles" + }, + { + "columnName": "SUM_SERVICE.numCalls_[]" + } + ] + }, + "row": [ + { + "column": [ + { + "string": "1615593600000" + }, + { + "string": "null" + }, + { + "string": "1616.0" + } + ] + }, + { + "column": [ + { + "string": "1615593600000" + }, + { + "string": "nginx-traceshop" + }, + { + "string": "1989.0" + } + ] + }, + { + "column": [ + { + "string": "1615597200000" + }, + { + "string": "null" + }, + { + "string": "2525.0" + } + ] + }, + { + "column": [ + { + "string": "1615597200000" + }, + { + "string": "nginx-traceshop" + }, + { + "string": "1977.0" + } + ] + }, + { + "column": [ + { + "string": "1615600800000" + }, + { + "string": "nginx-traceshop" + }, + { + "string": "1965.0" + } + ] + }, + { + "column": [ + { + "string": "1615600800000" + }, + { + "string": "null" + }, + { + "string": "2323.0" + } + ] + } + ] + } + } +] \ No newline at end of file diff --git a/gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json b/gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json new file mode 100644 index 00000000..00890003 --- /dev/null +++ b/gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json @@ -0,0 +1,322 @@ +[ + { + "request": { + "filter": { + "childFilter": [ + { + "lhs": { + "attributeExpression": { + "attributeId": "SERVICE.startTime" + } + }, + "operator": "GE", + "rhs": { + "literal": { + "value": { + "valueType": "LONG", + "long": "1615593600000" + } + } + } + }, + { + "lhs": { + "attributeExpression": { + "attributeId": "SERVICE.startTime" + } + }, + "operator": "LT", + "rhs": { + "literal": { + "value": { + "valueType": "LONG", + "long": "1615844349000" + } + } + } + } + ] + }, + "selection": [ + { + "function": { + "functionName": "SUM", + "arguments": [ + { + "attributeExpression": { + "attributeId": "SERVICE.numCalls" + } + } + ], + "alias": "SUM_SERVICE.numCalls_[]" + } + }, + { + "attributeExpression": { + "attributeId": "SERVICE.userRoles", + "alias": "SERVICE.userRoles" + } + } + ], + "groupBy": [ + { + "attributeExpression": { + "attributeId": "SERVICE.userRoles", + "alias": "SERVICE.userRoles" + } + } + ], + "limit": 2 + }, + "response": { + "isLastChunk": true, + "resultSetMetadata": { + "columnMetadata": [ + { + "columnName": "SERVICE.userRoles" + }, + { + "columnName": "SUM_SERVICE.numCalls_[]" + } + ] + }, + "row": [ + { + "column": [ + { + "string": "null" + }, + { + "string": "136098.0" + } + ] + } + ] + } + }, + { + "request": { + "filter": { + "childFilter": [ + { + "childFilter": [ + { + "lhs": { + "attributeExpression": { + "attributeId": "SERVICE.startTime" + } + }, + "operator": "GE", + "rhs": { + "literal": { + "value": { + "valueType": "LONG", + "long": "1615593600000" + } + } + } + }, + { + "lhs": { + "attributeExpression": { + "attributeId": "SERVICE.startTime" + } + }, + "operator": "LT", + "rhs": { + "literal": { + "value": { + "valueType": "LONG", + "long": "1615842000000" + } + } + } + } + ] + }, + { + "childFilter": [ + { + "lhs": { + "attributeExpression": { + "attributeId": "SERVICE.userRoles", + "alias": "SERVICE.userRoles" + } + }, + "operator": "IN", + "rhs": { + "literal": { + "value": { + "valueType": "STRING_ARRAY", + "stringArray": [ + "null" + ] + } + } + } + } + ] + } + ] + }, + "selection": [ + { + "function": { + "functionName": "SUM", + "arguments": [ + { + "attributeExpression": { + "attributeId": "SERVICE.numCalls" + } + } + ], + "alias": "SUM_SERVICE.numCalls_[]" + } + }, + { + "attributeExpression": { + "attributeId": "SERVICE.userRoles", + "alias": "SERVICE.userRoles" + } + } + ], + "groupBy": [ + { + "function": { + "functionName": "dateTimeConvert", + "arguments": [ + { + "attributeExpression": { + "attributeId": "SERVICE.startTime" + } + }, + { + "literal": { + "value": { + "string": "1:MILLISECONDS:EPOCH" + } + } + }, + { + "literal": { + "value": { + "string": "1:MILLISECONDS:EPOCH" + } + } + }, + { + "literal": { + "value": { + "string": "3600:SECONDS" + } + } + } + ] + } + }, + { + "attributeExpression": { + "attributeId": "SERVICE.userRoles", + "alias": "SERVICE.userRoles" + } + } + ], + "orderBy": [ + { + "expression": { + "function": { + "functionName": "dateTimeConvert", + "arguments": [ + { + "attributeExpression": { + "attributeId": "SERVICE.startTime" + } + }, + { + "literal": { + "value": { + "string": "1:MILLISECONDS:EPOCH" + } + } + }, + { + "literal": { + "value": { + "string": "1:MILLISECONDS:EPOCH" + } + } + }, + { + "literal": { + "value": { + "string": "3600:SECONDS" + } + } + } + ] + } + }, + "order": "DESC" + } + ], + "limit": 6 + }, + "response": { + "isLastChunk": true, + "resultSetMetadata": { + "columnMetadata": [ + { + "columnName": "dateTimeConvert" + }, + { + "columnName": "SERVICE.userRoles" + }, + { + "columnName": "SUM_SERVICE.numCalls_[]" + } + ] + }, + "row": [ + { + "column": [ + { + "string": "1615593600000" + }, + { + "string": "null" + }, + { + "string": "1616.0" + } + ] + }, + { + "column": [ + { + "string": "1615597200000" + }, + { + "string": "null" + }, + { + "string": "2525.0" + } + ] + }, + { + "column": [ + { + "string": "1615600800000" + }, + { + "string": "null" + }, + { + "string": "2323.0" + } + ] + } + ] + } + } +] \ No newline at end of file diff --git a/gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json b/gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json new file mode 100644 index 00000000..9e4e14b2 --- /dev/null +++ b/gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json @@ -0,0 +1,39 @@ +{ + "context": "SERVICE", + "startTimeMillis": "1615593600000", + "endTimeMillis": "1615844349000", + "filter": { + }, + "timeAggregation": [ + { + "period": { + "value": 3600, + "unit": "SECONDS" + }, + "aggregation": { + "function": { + "function": "SUM", + "arguments": [ + { + "columnIdentifier": { + "columnName": "SERVICE.numCalls" + } + } + ], + "alias": "SUM_SERVICE.numCalls_[]" + } + } + } + ], + "groupBy": [ + { + "columnIdentifier": { + "columnName": "SERVICE.userRoles", + "alias": "SERVICE.userRoles" + } + } + ], + "includeRestGroup": true, + "groupLimit": 2, + "limit": 6 +} \ No newline at end of file diff --git a/gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json b/gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json new file mode 100644 index 00000000..95530004 --- /dev/null +++ b/gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json @@ -0,0 +1,40 @@ +{ + "context": "SERVICE", + "startTimeMillis": "1615593600000", + "endTimeMillis": "1615844349000", + "filter": { + }, + "timeAggregation": [{ + "period": { + "value": 3600, + "unit": "SECONDS" + }, + "aggregation": { + "function": { + "function": "SUM", + "arguments": [{ + "columnIdentifier": { + "columnName": "SERVICE.numCalls" + } + }], + "alias": "SUM_SERVICE.numCalls_[]" + } + } + }], + "orderBy": [{ + "expression": { + "columnIdentifier": { + "columnName": "INTERVAL_START_TIME" + } + }, + "order": "DESC" + }], + "groupBy": [{ + "columnIdentifier": { + "columnName": "SERVICE.userRoles", + "alias": "SERVICE.userRoles" + } + }], + "groupLimit": 2, + "limit": 6 +} \ No newline at end of file diff --git a/gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json b/gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json new file mode 100644 index 00000000..95530004 --- /dev/null +++ b/gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json @@ -0,0 +1,40 @@ +{ + "context": "SERVICE", + "startTimeMillis": "1615593600000", + "endTimeMillis": "1615844349000", + "filter": { + }, + "timeAggregation": [{ + "period": { + "value": 3600, + "unit": "SECONDS" + }, + "aggregation": { + "function": { + "function": "SUM", + "arguments": [{ + "columnIdentifier": { + "columnName": "SERVICE.numCalls" + } + }], + "alias": "SUM_SERVICE.numCalls_[]" + } + } + }], + "orderBy": [{ + "expression": { + "columnIdentifier": { + "columnName": "INTERVAL_START_TIME" + } + }, + "order": "DESC" + }], + "groupBy": [{ + "columnIdentifier": { + "columnName": "SERVICE.userRoles", + "alias": "SERVICE.userRoles" + } + }], + "groupLimit": 2, + "limit": 6 +} \ No newline at end of file From cb44fd50f49c58a2397b275494f1b915b21f9c7f Mon Sep 17 00:00:00 2001 From: saxenakshitiz Date: Thu, 7 Dec 2023 20:50:55 +0530 Subject: [PATCH 6/9] remove response update --- .../explore/TheRestGroupRequestHandler.java | 10 +++++- ...AggregationsWithGroupByRequestHandler.java | 31 ------------------- ...it-and-the-rest-with-null-value-group.json | 6 ++-- ...mit-with-null-and-nonnull-value-group.json | 9 ++---- ...ith-group-limit-with-null-value-group.json | 9 ++---- 5 files changed, 17 insertions(+), 48 deletions(-) diff --git a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TheRestGroupRequestHandler.java b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TheRestGroupRequestHandler.java index 5d393158..278a8917 100644 --- a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TheRestGroupRequestHandler.java +++ b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TheRestGroupRequestHandler.java @@ -30,6 +30,7 @@ */ public class TheRestGroupRequestHandler { private static final String OTHER_COLUMN_VALUE = "__Other"; + private static final List LIST_WITH_NULL_STRING = List.of("null"); private final RequestHandlerWithSorting requestHandler; TheRestGroupRequestHandler(RequestHandlerWithSorting requestHandler) { @@ -234,7 +235,14 @@ private Stream getStringValues(Value value) { case STRING: return Stream.of(value.getString()); case STRING_ARRAY: - return value.getStringArrayList().stream(); + // Handle special case when "null" string is returned as string array value(default value + // scenario). This will be converted to empty list in value converter. In such a case use + // list with "null" value + if (value.getStringArrayList().isEmpty()) { + return LIST_WITH_NULL_STRING.stream(); + } else { + return value.getStringArrayList().stream(); + } default: return Stream.of(); } diff --git a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TimeAggregationsWithGroupByRequestHandler.java b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TimeAggregationsWithGroupByRequestHandler.java index 45d49e50..57d36f18 100644 --- a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TimeAggregationsWithGroupByRequestHandler.java +++ b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TimeAggregationsWithGroupByRequestHandler.java @@ -80,8 +80,6 @@ public ExploreResponse.Builder handleRequest( timeAggregationsRequestHandler.handleRequest( timeAggregationsRequestContext, timeAggregationsRequest); - updateExploreResponse(timeAggregationsResponse); - // 3. If includeRestGroup is set, and we have not reached limit // then invoke TheRestGroupRequestHandler if (request.getIncludeRestGroup() @@ -306,33 +304,4 @@ private Map remapAttributeMetadataByResultName( .collect(Collectors.toUnmodifiableList()), attributeMetadataByIdMap); } - - private void updateExploreResponse(ExploreResponse.Builder timeAggregationsResponse) { - List updatedRows = - timeAggregationsResponse.getRowList().stream() - .map( - row -> { - Row.Builder builder = row.toBuilder(); - builder - .getColumnsMap() - .forEach( - (k, v) -> { - // if value is of tye string array and value list is empty, then need to - // add "null" as value list - if (v.getValueType().equals(ValueType.STRING_ARRAY) - && v.getStringArrayList().isEmpty()) { - builder.putColumns( - k, - Value.newBuilder() - .setValueType(ValueType.STRING_ARRAY) - .addAllStringArray(LIST_WITH_NULL_STRING) - .build()); - } - }); - return builder.build(); - }) - .collect(Collectors.toUnmodifiableList()); - timeAggregationsResponse.clearRow(); - timeAggregationsResponse.addAllRow(updatedRows); - } } diff --git a/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json b/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json index 96b04c09..7f48add7 100644 --- a/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json +++ b/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json @@ -7,8 +7,7 @@ "long": "1615593600000" }, "SERVICE.userRoles": { - "valueType": "STRING_ARRAY", - "string_array": ["null"] + "valueType": "STRING_ARRAY" }, "SUM_SERVICE.numCalls_[]": { "valueType": "LONG", @@ -39,8 +38,7 @@ "long": "1615597200000" }, "SERVICE.userRoles": { - "valueType": "STRING_ARRAY", - "string_array": ["null"] + "valueType": "STRING_ARRAY" }, "SUM_SERVICE.numCalls_[]": { "valueType": "LONG", diff --git a/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json b/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json index 395a4f30..27b5334f 100644 --- a/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json +++ b/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json @@ -6,8 +6,7 @@ "long": "1615593600000" }, "SERVICE.userRoles": { - "valueType": "STRING_ARRAY", - "string_array": ["null"] + "valueType": "STRING_ARRAY" }, "SUM_SERVICE.numCalls_[]": { "valueType": "LONG", @@ -36,8 +35,7 @@ "long": "1615597200000" }, "SERVICE.userRoles": { - "valueType": "STRING_ARRAY", - "string_array": ["null"] + "valueType": "STRING_ARRAY" }, "SUM_SERVICE.numCalls_[]": { "valueType": "LONG", @@ -81,8 +79,7 @@ "long": "1615600800000" }, "SERVICE.userRoles": { - "valueType": "STRING_ARRAY", - "string_array": ["null"] + "valueType": "STRING_ARRAY" }, "SUM_SERVICE.numCalls_[]": { "valueType": "LONG", diff --git a/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json b/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json index bde4b93e..84a8f6d4 100644 --- a/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json +++ b/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json @@ -6,8 +6,7 @@ "long": "1615593600000" }, "SERVICE.userRoles": { - "valueType": "STRING_ARRAY", - "string_array": ["null"] + "valueType": "STRING_ARRAY" }, "SUM_SERVICE.numCalls_[]": { "valueType": "LONG", @@ -21,8 +20,7 @@ "long": "1615597200000" }, "SERVICE.userRoles": { - "valueType": "STRING_ARRAY", - "string_array": ["null"] + "valueType": "STRING_ARRAY" }, "SUM_SERVICE.numCalls_[]": { "valueType": "LONG", @@ -36,8 +34,7 @@ "long": "1615600800000" }, "SERVICE.userRoles": { - "valueType": "STRING_ARRAY", - "string_array": ["null"] + "valueType": "STRING_ARRAY" }, "SUM_SERVICE.numCalls_[]": { "valueType": "LONG", From 76e4bb420f73b3bbfc7460adbb668e9ff2b6efe4 Mon Sep 17 00:00:00 2001 From: saxenakshitiz Date: Thu, 7 Dec 2023 22:02:39 +0530 Subject: [PATCH 7/9] address review comments --- .../common/converters/QueryRequestUtil.java | 14 ++++++++++++++ .../explore/TheRestGroupRequestHandler.java | 12 +++--------- .../TimeAggregationsWithGroupByRequestHandler.java | 13 +++---------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/QueryRequestUtil.java b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/QueryRequestUtil.java index 42541fa4..46b1df4c 100644 --- a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/QueryRequestUtil.java +++ b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/QueryRequestUtil.java @@ -20,6 +20,7 @@ public class QueryRequestUtil { private static final String COUNT_FUNCTION_NAME = "COUNT"; private static final String DISTINCTCOUNT_FUNCTION_NAME = "DISTINCTCOUNT"; + private static final List LIST_WITH_NULL_STRING = List.of("null"); public static Filter createBetweenTimesFilter(String columnName, long lower, long higher) { return Filter.newBuilder() @@ -127,4 +128,17 @@ public static Expression createTimeColumnGroupByExpression( .addArguments(createStringLiteralExpression(periodSecs + ":SECONDS"))) .build(); } + + public static List convertStringArrayValue( + org.hypertrace.gateway.service.v1.common.Value value) { + // The downstream QS service returns the default value "null" for a string array when it is + // empty. GW returns an empty list as output. This transformation occurs in the value converter. + // To handle this scenario when querying downstream with an empty list, set its default value to + // "null." + if (value.getStringArrayList().isEmpty()) { + return LIST_WITH_NULL_STRING; + } else { + return value.getStringArrayList(); + } + } } diff --git a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TheRestGroupRequestHandler.java b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TheRestGroupRequestHandler.java index 278a8917..52acc6a7 100644 --- a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TheRestGroupRequestHandler.java +++ b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TheRestGroupRequestHandler.java @@ -1,5 +1,7 @@ package org.hypertrace.gateway.service.explore; +import static org.hypertrace.gateway.service.common.converters.QueryRequestUtil.convertStringArrayValue; + import com.google.common.collect.ImmutableSet; import java.util.List; import java.util.Map; @@ -30,7 +32,6 @@ */ public class TheRestGroupRequestHandler { private static final String OTHER_COLUMN_VALUE = "__Other"; - private static final List LIST_WITH_NULL_STRING = List.of("null"); private final RequestHandlerWithSorting requestHandler; TheRestGroupRequestHandler(RequestHandlerWithSorting requestHandler) { @@ -235,14 +236,7 @@ private Stream getStringValues(Value value) { case STRING: return Stream.of(value.getString()); case STRING_ARRAY: - // Handle special case when "null" string is returned as string array value(default value - // scenario). This will be converted to empty list in value converter. In such a case use - // list with "null" value - if (value.getStringArrayList().isEmpty()) { - return LIST_WITH_NULL_STRING.stream(); - } else { - return value.getStringArrayList().stream(); - } + return convertStringArrayValue(value).stream(); default: return Stream.of(); } diff --git a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TimeAggregationsWithGroupByRequestHandler.java b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TimeAggregationsWithGroupByRequestHandler.java index 57d36f18..2c988008 100644 --- a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TimeAggregationsWithGroupByRequestHandler.java +++ b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/TimeAggregationsWithGroupByRequestHandler.java @@ -1,5 +1,7 @@ package org.hypertrace.gateway.service.explore; +import static org.hypertrace.gateway.service.common.converters.QueryRequestUtil.convertStringArrayValue; + import com.google.common.collect.Streams; import java.util.List; import java.util.Map; @@ -30,8 +32,6 @@ public class TimeAggregationsWithGroupByRequestHandler implements IRequestHandle private static final Logger LOG = LoggerFactory.getLogger(TimeAggregationsWithGroupByRequestHandler.class); - private static final List LIST_WITH_NULL_STRING = List.of("null"); - private final AttributeMetadataProvider attributeMetadataProvider; private final RequestHandler normalRequestHandler; private final TimeAggregationsRequestHandler timeAggregationsRequestHandler; @@ -230,14 +230,7 @@ private void buildInClauseFilterValue(Value value, Value.Builder valueBuilder) { valueBuilder.addStringArray(value.getString()); break; case STRING_ARRAY: - // Handle special case when "null" string is returned as string array value(default value - // scenario). This will be converted to empty list in value converter. In such a case use - // list with "null" value - if (value.getStringArrayList().isEmpty()) { - valueBuilder.addAllStringArray(LIST_WITH_NULL_STRING); - } else { - valueBuilder.addAllStringArray(value.getStringArrayList()); - } + valueBuilder.addAllStringArray(convertStringArrayValue(value)); break; case LONG: valueBuilder.addLongArray(value.getLong()); From 53737a670a410cb6b05727ca18b67cfbc9d18363 Mon Sep 17 00:00:00 2001 From: saxenakshitiz Date: Thu, 7 Dec 2023 23:03:13 +0530 Subject: [PATCH 8/9] address review comments --- .../test/resources/attributes/attributes.json | 4 +- ...it-and-the-rest-with-null-value-group.json | 16 ++++---- ...mit-with-null-and-nonnull-value-group.json | 18 ++++----- ...ith-group-limit-with-null-value-group.json | 6 +-- ...it-and-the-rest-with-null-value-group.json | 38 +++++++++---------- ...mit-with-null-and-nonnull-value-group.json | 34 ++++++++--------- ...ith-group-limit-with-null-value-group.json | 24 ++++++------ ...it-and-the-rest-with-null-value-group.json | 4 +- ...mit-with-null-and-nonnull-value-group.json | 4 +- ...ith-group-limit-with-null-value-group.json | 4 +- 10 files changed, 76 insertions(+), 76 deletions(-) diff --git a/gateway-service-impl/src/test/resources/attributes/attributes.json b/gateway-service-impl/src/test/resources/attributes/attributes.json index 9e3cb0e8..2785b91b 100644 --- a/gateway-service-impl/src/test/resources/attributes/attributes.json +++ b/gateway-service-impl/src/test/resources/attributes/attributes.json @@ -946,9 +946,9 @@ ] }, { - "fqn": "Service.userRoles", + "fqn": "Service.labels", "valueKind": "TYPE_STRING_ARRAY", - "key": "userRoles", + "key": "labels", "displayName": "Service User Roles", "scopeString": "SERVICE", "type": "ATTRIBUTE", diff --git a/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json b/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json index 7f48add7..c4106795 100644 --- a/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json +++ b/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json @@ -6,7 +6,7 @@ "valueType": "LONG", "long": "1615593600000" }, - "SERVICE.userRoles": { + "SERVICE.labels": { "valueType": "STRING_ARRAY" }, "SUM_SERVICE.numCalls_[]": { @@ -21,9 +21,9 @@ "valueType": "LONG", "long": "1615593600000" }, - "SERVICE.userRoles": { + "SERVICE.labels": { "valueType": "STRING_ARRAY", - "string_array": ["nginx-traceshop"] + "string_array": ["label1"] }, "SUM_SERVICE.numCalls_[]": { "valueType": "LONG", @@ -37,7 +37,7 @@ "valueType": "LONG", "long": "1615597200000" }, - "SERVICE.userRoles": { + "SERVICE.labels": { "valueType": "STRING_ARRAY" }, "SUM_SERVICE.numCalls_[]": { @@ -52,9 +52,9 @@ "valueType": "LONG", "long": "1615597200000" }, - "SERVICE.userRoles": { + "SERVICE.labels": { "valueType": "STRING_ARRAY", - "string_array": ["nginx-traceshop"] + "string_array": ["label1"] }, "SUM_SERVICE.numCalls_[]": { "valueType": "LONG", @@ -72,7 +72,7 @@ "valueType": "LONG", "long": "27485" }, - "SERVICE.userRoles": { + "SERVICE.labels": { "valueType": "STRING", "string": "__Other" } @@ -88,7 +88,7 @@ "valueType": "LONG", "long": "27192" }, - "SERVICE.userRoles": { + "SERVICE.labels": { "valueType": "STRING", "string": "__Other" } diff --git a/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json b/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json index 27b5334f..682b8dc6 100644 --- a/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json +++ b/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json @@ -5,7 +5,7 @@ "valueType": "LONG", "long": "1615593600000" }, - "SERVICE.userRoles": { + "SERVICE.labels": { "valueType": "STRING_ARRAY" }, "SUM_SERVICE.numCalls_[]": { @@ -19,9 +19,9 @@ "valueType": "LONG", "long": "1615593600000" }, - "SERVICE.userRoles": { + "SERVICE.labels": { "valueType": "STRING_ARRAY", - "string_array": ["nginx-traceshop"] + "string_array": ["label1"] }, "SUM_SERVICE.numCalls_[]": { "valueType": "LONG", @@ -34,7 +34,7 @@ "valueType": "LONG", "long": "1615597200000" }, - "SERVICE.userRoles": { + "SERVICE.labels": { "valueType": "STRING_ARRAY" }, "SUM_SERVICE.numCalls_[]": { @@ -48,9 +48,9 @@ "valueType": "LONG", "long": "1615597200000" }, - "SERVICE.userRoles": { + "SERVICE.labels": { "valueType": "STRING_ARRAY", - "string_array": ["nginx-traceshop"] + "string_array": ["label1"] }, "SUM_SERVICE.numCalls_[]": { "valueType": "LONG", @@ -63,9 +63,9 @@ "valueType": "LONG", "long": "1615600800000" }, - "SERVICE.userRoles": { + "SERVICE.labels": { "valueType": "STRING_ARRAY", - "string_array": ["nginx-traceshop"] + "string_array": ["label1"] }, "SUM_SERVICE.numCalls_[]": { "valueType": "LONG", @@ -78,7 +78,7 @@ "valueType": "LONG", "long": "1615600800000" }, - "SERVICE.userRoles": { + "SERVICE.labels": { "valueType": "STRING_ARRAY" }, "SUM_SERVICE.numCalls_[]": { diff --git a/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json b/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json index 84a8f6d4..d8548568 100644 --- a/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json +++ b/gateway-service-impl/src/test/resources/expected-test-responses/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json @@ -5,7 +5,7 @@ "valueType": "LONG", "long": "1615593600000" }, - "SERVICE.userRoles": { + "SERVICE.labels": { "valueType": "STRING_ARRAY" }, "SUM_SERVICE.numCalls_[]": { @@ -19,7 +19,7 @@ "valueType": "LONG", "long": "1615597200000" }, - "SERVICE.userRoles": { + "SERVICE.labels": { "valueType": "STRING_ARRAY" }, "SUM_SERVICE.numCalls_[]": { @@ -33,7 +33,7 @@ "valueType": "LONG", "long": "1615600800000" }, - "SERVICE.userRoles": { + "SERVICE.labels": { "valueType": "STRING_ARRAY" }, "SUM_SERVICE.numCalls_[]": { diff --git a/gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json b/gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json index 66332df5..ce56343e 100644 --- a/gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json +++ b/gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json @@ -53,16 +53,16 @@ }, { "attributeExpression": { - "attributeId": "SERVICE.userRoles", - "alias": "SERVICE.userRoles" + "attributeId": "SERVICE.labels", + "alias": "SERVICE.labels" } } ], "groupBy": [ { "attributeExpression": { - "attributeId": "SERVICE.userRoles", - "alias": "SERVICE.userRoles" + "attributeId": "SERVICE.labels", + "alias": "SERVICE.labels" } } ], @@ -73,7 +73,7 @@ "resultSetMetadata": { "columnMetadata": [ { - "columnName": "SERVICE.userRoles" + "columnName": "SERVICE.labels" }, { "columnName": "SUM_SERVICE.numCalls_[]" @@ -94,7 +94,7 @@ { "column": [ { - "string": "nginx-traceshop" + "string": "label1" }, { "string": "136269.0" @@ -149,8 +149,8 @@ { "lhs": { "attributeExpression": { - "attributeId": "SERVICE.userRoles", - "alias": "SERVICE.userRoles" + "attributeId": "SERVICE.labels", + "alias": "SERVICE.labels" } }, "operator": "IN", @@ -160,7 +160,7 @@ "valueType": "STRING_ARRAY", "stringArray": [ "null", - "nginx-traceshop" + "label1" ] } } @@ -186,8 +186,8 @@ }, { "attributeExpression": { - "attributeId": "SERVICE.userRoles", - "alias": "SERVICE.userRoles" + "attributeId": "SERVICE.labels", + "alias": "SERVICE.labels" } } ], @@ -227,8 +227,8 @@ }, { "attributeExpression": { - "attributeId": "SERVICE.userRoles", - "alias": "SERVICE.userRoles" + "attributeId": "SERVICE.labels", + "alias": "SERVICE.labels" } } ], @@ -279,7 +279,7 @@ "columnName": "dateTimeConvert" }, { - "columnName": "SERVICE.userRoles" + "columnName": "SERVICE.labels" }, { "columnName": "SUM_SERVICE.numCalls_[]" @@ -306,7 +306,7 @@ "string": "1615593600000" }, { - "string": "nginx-traceshop" + "string": "label1" }, { "string": "1989.0" @@ -332,7 +332,7 @@ "string": "1615597200000" }, { - "string": "nginx-traceshop" + "string": "label1" }, { "string": "1977.0" @@ -387,8 +387,8 @@ { "lhs": { "attributeExpression": { - "attributeId": "SERVICE.userRoles", - "alias": "SERVICE.userRoles" + "attributeId": "SERVICE.labels", + "alias": "SERVICE.labels" } }, "operator": "NOT_IN", @@ -398,7 +398,7 @@ "valueType": "STRING_ARRAY", "stringArray": [ "null", - "nginx-traceshop" + "label1" ] } } diff --git a/gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json b/gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json index f7ce28ed..e1ae767f 100644 --- a/gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json +++ b/gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json @@ -53,16 +53,16 @@ }, { "attributeExpression": { - "attributeId": "SERVICE.userRoles", - "alias": "SERVICE.userRoles" + "attributeId": "SERVICE.labels", + "alias": "SERVICE.labels" } } ], "groupBy": [ { "attributeExpression": { - "attributeId": "SERVICE.userRoles", - "alias": "SERVICE.userRoles" + "attributeId": "SERVICE.labels", + "alias": "SERVICE.labels" } } ], @@ -73,7 +73,7 @@ "resultSetMetadata": { "columnMetadata": [ { - "columnName": "SERVICE.userRoles" + "columnName": "SERVICE.labels" }, { "columnName": "SUM_SERVICE.numCalls_[]" @@ -94,7 +94,7 @@ { "column": [ { - "string": "nginx-traceshop" + "string": "label1" }, { "string": "136269.0" @@ -149,8 +149,8 @@ { "lhs": { "attributeExpression": { - "attributeId": "SERVICE.userRoles", - "alias": "SERVICE.userRoles" + "attributeId": "SERVICE.labels", + "alias": "SERVICE.labels" } }, "operator": "IN", @@ -160,7 +160,7 @@ "valueType": "STRING_ARRAY", "stringArray": [ "null", - "nginx-traceshop" + "label1" ] } } @@ -186,8 +186,8 @@ }, { "attributeExpression": { - "attributeId": "SERVICE.userRoles", - "alias": "SERVICE.userRoles" + "attributeId": "SERVICE.labels", + "alias": "SERVICE.labels" } } ], @@ -227,8 +227,8 @@ }, { "attributeExpression": { - "attributeId": "SERVICE.userRoles", - "alias": "SERVICE.userRoles" + "attributeId": "SERVICE.labels", + "alias": "SERVICE.labels" } } ], @@ -280,7 +280,7 @@ "columnName": "dateTimeConvert" }, { - "columnName": "SERVICE.userRoles" + "columnName": "SERVICE.labels" }, { "columnName": "SUM_SERVICE.numCalls_[]" @@ -307,7 +307,7 @@ "string": "1615593600000" }, { - "string": "nginx-traceshop" + "string": "label1" }, { "string": "1989.0" @@ -333,7 +333,7 @@ "string": "1615597200000" }, { - "string": "nginx-traceshop" + "string": "label1" }, { "string": "1977.0" @@ -346,7 +346,7 @@ "string": "1615600800000" }, { - "string": "nginx-traceshop" + "string": "label1" }, { "string": "1965.0" diff --git a/gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json b/gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json index 00890003..01b3cc25 100644 --- a/gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json +++ b/gateway-service-impl/src/test/resources/query-service-requests-and-responses/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json @@ -53,16 +53,16 @@ }, { "attributeExpression": { - "attributeId": "SERVICE.userRoles", - "alias": "SERVICE.userRoles" + "attributeId": "SERVICE.labels", + "alias": "SERVICE.labels" } } ], "groupBy": [ { "attributeExpression": { - "attributeId": "SERVICE.userRoles", - "alias": "SERVICE.userRoles" + "attributeId": "SERVICE.labels", + "alias": "SERVICE.labels" } } ], @@ -73,7 +73,7 @@ "resultSetMetadata": { "columnMetadata": [ { - "columnName": "SERVICE.userRoles" + "columnName": "SERVICE.labels" }, { "columnName": "SUM_SERVICE.numCalls_[]" @@ -139,8 +139,8 @@ { "lhs": { "attributeExpression": { - "attributeId": "SERVICE.userRoles", - "alias": "SERVICE.userRoles" + "attributeId": "SERVICE.labels", + "alias": "SERVICE.labels" } }, "operator": "IN", @@ -175,8 +175,8 @@ }, { "attributeExpression": { - "attributeId": "SERVICE.userRoles", - "alias": "SERVICE.userRoles" + "attributeId": "SERVICE.labels", + "alias": "SERVICE.labels" } } ], @@ -216,8 +216,8 @@ }, { "attributeExpression": { - "attributeId": "SERVICE.userRoles", - "alias": "SERVICE.userRoles" + "attributeId": "SERVICE.labels", + "alias": "SERVICE.labels" } } ], @@ -269,7 +269,7 @@ "columnName": "dateTimeConvert" }, { - "columnName": "SERVICE.userRoles" + "columnName": "SERVICE.labels" }, { "columnName": "SUM_SERVICE.numCalls_[]" diff --git a/gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json b/gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json index 9e4e14b2..8cc3052e 100644 --- a/gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json +++ b/gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-and-the-rest-with-null-value-group.json @@ -28,8 +28,8 @@ "groupBy": [ { "columnIdentifier": { - "columnName": "SERVICE.userRoles", - "alias": "SERVICE.userRoles" + "columnName": "SERVICE.labels", + "alias": "SERVICE.labels" } } ], diff --git a/gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json b/gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json index 95530004..f0f3df51 100644 --- a/gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json +++ b/gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-with-null-and-nonnull-value-group.json @@ -31,8 +31,8 @@ }], "groupBy": [{ "columnIdentifier": { - "columnName": "SERVICE.userRoles", - "alias": "SERVICE.userRoles" + "columnName": "SERVICE.labels", + "alias": "SERVICE.labels" } }], "groupLimit": 2, diff --git a/gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json b/gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json index 95530004..f0f3df51 100644 --- a/gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json +++ b/gateway-service-impl/src/test/resources/test-requests/explore/grouped-time-aggregation-with-group-limit-with-null-value-group.json @@ -31,8 +31,8 @@ }], "groupBy": [{ "columnIdentifier": { - "columnName": "SERVICE.userRoles", - "alias": "SERVICE.userRoles" + "columnName": "SERVICE.labels", + "alias": "SERVICE.labels" } }], "groupLimit": 2, From a17bd2b48c21e930b5d6db69f641f1c5415b328b Mon Sep 17 00:00:00 2001 From: saxenakshitiz Date: Thu, 7 Dec 2023 23:29:12 +0530 Subject: [PATCH 9/9] address review comments --- .../gateway/service/common/converters/QueryRequestUtil.java | 2 ++ .../src/test/resources/attributes/attributes.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/QueryRequestUtil.java b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/QueryRequestUtil.java index 46b1df4c..b0235e86 100644 --- a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/QueryRequestUtil.java +++ b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/QueryRequestUtil.java @@ -135,6 +135,8 @@ public static List convertStringArrayValue( // empty. GW returns an empty list as output. This transformation occurs in the value converter. // To handle this scenario when querying downstream with an empty list, set its default value to // "null." + // Refer to {@linkplain StringToAttributeKindConverter#convertToArray} to check how QS response + // for string array column is converted if (value.getStringArrayList().isEmpty()) { return LIST_WITH_NULL_STRING; } else { diff --git a/gateway-service-impl/src/test/resources/attributes/attributes.json b/gateway-service-impl/src/test/resources/attributes/attributes.json index 2785b91b..48c3665c 100644 --- a/gateway-service-impl/src/test/resources/attributes/attributes.json +++ b/gateway-service-impl/src/test/resources/attributes/attributes.json @@ -949,7 +949,7 @@ "fqn": "Service.labels", "valueKind": "TYPE_STRING_ARRAY", "key": "labels", - "displayName": "Service User Roles", + "displayName": "Service Labels", "scopeString": "SERVICE", "type": "ATTRIBUTE", "sources": [