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

Commit

Permalink
Support for MAX, MIN, SUM on timestamp (#131)
Browse files Browse the repository at this point in the history
* adding support for max,min,sum on timestamp

* snyk

* removing sum for timestamp

Co-authored-by: Apoorv Jain <[email protected]>
  • Loading branch information
japoorv and Apoorv Jain authored May 12, 2022
1 parent b0cb224 commit 6bd4b24
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
4 changes: 4 additions & 0 deletions gateway-service-impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ dependencies {
testImplementation("org.mockito:mockito-inline:4.3.1")
testImplementation("org.apache.logging.log4j:log4j-slf4j-impl:2.17.1")
testImplementation("io.grpc:grpc-netty:1.44.0")

constraints {
testRuntimeOnly("io.netty:netty-common:4.1.77.Final")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public Value doConvert(String value, AttributeKind attributeKind, Value.Builder

case TYPE_TIMESTAMP:
valueBuilder.setValueType(ValueType.TIMESTAMP);
valueBuilder.setTimestamp(Long.parseLong(value));
valueBuilder.setTimestamp(Double.valueOf(value).longValue());
return valueBuilder.build();

case TYPE_STRING_MAP:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,35 @@ public static AttributeKind getValueTypeForFunctionType(
return AttributeKind.TYPE_INT64;
case MIN:
case MAX:
{
AttributeKind attributeKind = attributeMetadata.getValueKind();
// Min/Max/Sum function only applicable to numerical data
Preconditions.checkArgument(
AttributeKind.TYPE_DOUBLE.equals(attributeKind)
|| AttributeKind.TYPE_INT64.equals(attributeKind)
|| AttributeKind.TYPE_TIMESTAMP.equals(attributeKind),
"Incompatible data type for this function. Function : %s,"
+ " Attribute Kind: %s. Attribute ID : %s",
functionType.name(),
attributeKind.name(),
attributeMetadata.getId());
return attributeKind;
}
case SUM:
AttributeKind attributeKind = attributeMetadata.getValueKind();
// Min/Max/Sum function only applicable to numerical data
Preconditions.checkArgument(
AttributeKind.TYPE_DOUBLE.equals(attributeKind)
|| AttributeKind.TYPE_INT64.equals(attributeKind),
"Incompatible data type for this function. Function : %s,"
+ " Attribute Kind: %s. Attribute ID : %s",
functionType.name(),
attributeKind.name(),
attributeMetadata.getId());
{
AttributeKind attributeKind = attributeMetadata.getValueKind();
// Min/Max/Sum function only applicable to numerical data
Preconditions.checkArgument(
AttributeKind.TYPE_DOUBLE.equals(attributeKind)
|| AttributeKind.TYPE_INT64.equals(attributeKind),
"Incompatible data type for this function. Function : %s,"
+ " Attribute Kind: %s. Attribute ID : %s",
functionType.name(),
attributeKind.name(),
attributeMetadata.getId());

return attributeKind;
return attributeKind;
}
case AVGRATE:
case AVG:
case PERCENTILE:
Expand Down
4 changes: 4 additions & 0 deletions gateway-service/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ dependencies {

runtimeOnly("io.grpc:grpc-netty:1.44.0")
runtimeOnly("org.apache.logging.log4j:log4j-slf4j-impl:2.17.1")

constraints {
runtimeOnly("io.netty:netty-common:4.1.77.Final")
}
}

application {
Expand Down

0 comments on commit 6bd4b24

Please sign in to comment.