From f479a60d98c3fb721eca3d7d3ee6344c58c24e83 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Tue, 8 Nov 2022 17:18:40 -0800 Subject: [PATCH] Update missed valueOf calls in prometheus Signed-off-by: Joshua Li --- .../implementation/QueryRangeFunctionImplementation.java | 2 +- .../storage/querybuilder/TimeRangeParametersResolver.java | 2 +- .../functions/QueryRangeFunctionImplementationTest.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/prometheus/src/main/java/org/opensearch/sql/prometheus/functions/implementation/QueryRangeFunctionImplementation.java b/prometheus/src/main/java/org/opensearch/sql/prometheus/functions/implementation/QueryRangeFunctionImplementation.java index bccb9c3bff..2d3710037a 100644 --- a/prometheus/src/main/java/org/opensearch/sql/prometheus/functions/implementation/QueryRangeFunctionImplementation.java +++ b/prometheus/src/main/java/org/opensearch/sql/prometheus/functions/implementation/QueryRangeFunctionImplementation.java @@ -83,7 +83,7 @@ private PrometheusQueryRequest buildQueryFromQueryRangeFunction(List arguments.forEach(arg -> { String argName = ((NamedArgumentExpression) arg).getArgName(); Expression argValue = ((NamedArgumentExpression) arg).getValue(); - ExprValue literalValue = argValue.valueOf(null); + ExprValue literalValue = argValue.valueOf(); switch (argName) { case QUERY: prometheusQueryRequest diff --git a/prometheus/src/main/java/org/opensearch/sql/prometheus/storage/querybuilder/TimeRangeParametersResolver.java b/prometheus/src/main/java/org/opensearch/sql/prometheus/storage/querybuilder/TimeRangeParametersResolver.java index 6c338d61a6..810ed71379 100644 --- a/prometheus/src/main/java/org/opensearch/sql/prometheus/storage/querybuilder/TimeRangeParametersResolver.java +++ b/prometheus/src/main/java/org/opensearch/sql/prometheus/storage/querybuilder/TimeRangeParametersResolver.java @@ -57,7 +57,7 @@ public Void visitFunction(FunctionExpression func, Object context) { ReferenceExpression ref = (ReferenceExpression) func.getArguments().get(0); Expression rightExpr = func.getArguments().get(1); if (ref.getAttr().equals("@timestamp")) { - ExprValue literalValue = rightExpr.valueOf(null); + ExprValue literalValue = rightExpr.valueOf(); if (func.getFunctionName().getFunctionName().contains(">")) { startTime = literalValue.timestampValue().toEpochMilli() / 1000; } diff --git a/prometheus/src/test/java/org/opensearch/sql/prometheus/functions/QueryRangeFunctionImplementationTest.java b/prometheus/src/test/java/org/opensearch/sql/prometheus/functions/QueryRangeFunctionImplementationTest.java index f2a54b7347..98195eecf7 100644 --- a/prometheus/src/test/java/org/opensearch/sql/prometheus/functions/QueryRangeFunctionImplementationTest.java +++ b/prometheus/src/test/java/org/opensearch/sql/prometheus/functions/QueryRangeFunctionImplementationTest.java @@ -48,7 +48,7 @@ void testValueOfAndTypeAndToString() { QueryRangeFunctionImplementation queryRangeFunctionImplementation = new QueryRangeFunctionImplementation(functionName, namedArgumentExpressionList, client); UnsupportedOperationException exception = assertThrows(UnsupportedOperationException.class, - () -> queryRangeFunctionImplementation.valueOf(null)); + () -> queryRangeFunctionImplementation.valueOf()); assertEquals("Prometheus defined function [query_range] is only " + "supported in SOURCE clause with prometheus connector catalog", exception.getMessage()); assertEquals("query_range(query=\"http_latency\", starttime=12345, endtime=12345, step=14)",