This is an automated email from the ASF dual-hosted git repository.
rongr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 5ca72a377d add reserved keyword inbuilt function evaluator (#9528)
5ca72a377d is described below
commit 5ca72a377d98b5b4e98141ed1c2c14f8bc6e9961
Author: Rong Rong <[email protected]>
AuthorDate: Tue Oct 4 14:49:09 2022 -0700
add reserved keyword inbuilt function evaluator (#9528)
Co-authored-by: Rong Rong <[email protected]>
---
.../data/function/InbuiltFunctionEvaluatorTest.java | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git
a/pinot-core/src/test/java/org/apache/pinot/core/data/function/InbuiltFunctionEvaluatorTest.java
b/pinot-core/src/test/java/org/apache/pinot/core/data/function/InbuiltFunctionEvaluatorTest.java
index d747e6acd5..5c6835e293 100644
---
a/pinot-core/src/test/java/org/apache/pinot/core/data/function/InbuiltFunctionEvaluatorTest.java
+++
b/pinot-core/src/test/java/org/apache/pinot/core/data/function/InbuiltFunctionEvaluatorTest.java
@@ -23,6 +23,8 @@ import java.util.Collections;
import org.apache.pinot.common.function.FunctionRegistry;
import org.apache.pinot.segment.local.function.InbuiltFunctionEvaluator;
import org.apache.pinot.spi.data.readers.GenericRow;
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
@@ -56,6 +58,21 @@ public class InbuiltFunctionEvaluatorTest {
}
}
+ @Test
+ public void testScalarWrapperWithReservedKeywordExpression() {
+ String expression = "dateTrunc('MONTH', \"date\")";
+ InbuiltFunctionEvaluator evaluator = new
InbuiltFunctionEvaluator(expression);
+ assertEquals(evaluator.getArguments(), Collections.singletonList("date"));
+ GenericRow row = new GenericRow();
+ for (int i = 1; i < 9; i++) {
+ DateTime dt = new DateTime(String.format("2020-0%d-15T12:00:00", i));
+ long millis = dt.getMillis();
+ DateTime truncDt =
dt.withZone(DateTimeZone.UTC).withDayOfMonth(1).withHourOfDay(0).withMillisOfDay(0);
+ row.putValue("date", millis);
+ assertEquals(evaluator.evaluate(row), truncDt.getMillis());
+ }
+ }
+
@Test
public void testScalarWrapperNameWithOverrides() {
String expr = String.format("regexp_extract(testColumn, '%s')",
"(.*)([\\d]+)");
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]