This is an automated email from the ASF dual-hosted git repository.

yashmayya 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 a914940b37 Fix timestamp literal handling in the multi-stage query 
engine (#14502)
a914940b37 is described below

commit a914940b378ae5a6b7b489c570d5c0ba73100730
Author: Yash Mayya <yash.ma...@gmail.com>
AuthorDate: Wed Nov 20 15:03:38 2024 +0700

    Fix timestamp literal handling in the multi-stage query engine (#14502)
---
 .../apache/pinot/query/planner/logical/RexExpressionUtils.java | 10 +++++++++-
 .../java/org/apache/pinot/query/QueryEnvironmentTestBase.java  |  3 +++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git 
a/pinot-query-planner/src/main/java/org/apache/pinot/query/planner/logical/RexExpressionUtils.java
 
b/pinot-query-planner/src/main/java/org/apache/pinot/query/planner/logical/RexExpressionUtils.java
index bf92e28f8e..a1b7075850 100644
--- 
a/pinot-query-planner/src/main/java/org/apache/pinot/query/planner/logical/RexExpressionUtils.java
+++ 
b/pinot-query-planner/src/main/java/org/apache/pinot/query/planner/logical/RexExpressionUtils.java
@@ -255,7 +255,15 @@ public class RexExpressionUtils {
         value = Boolean.TRUE.equals(value) ? BooleanUtils.INTERNAL_TRUE : 
BooleanUtils.INTERNAL_FALSE;
         break;
       case TIMESTAMP:
-        value = ((Calendar) value).getTimeInMillis();
+        if (value instanceof Calendar) {
+          value = ((Calendar) value).getTimeInMillis();
+        } else if (value instanceof TimestampString) {
+          value = ((TimestampString) value).getMillisSinceEpoch();
+        } else if (value instanceof Long) {
+          // Already in millis
+        } else {
+          throw new IllegalStateException("Unsupported value type for 
TIMESTAMP: " + value.getClass().getName());
+        }
         break;
       case STRING:
         value = ((NlsString) value).getValue();
diff --git 
a/pinot-query-planner/src/test/java/org/apache/pinot/query/QueryEnvironmentTestBase.java
 
b/pinot-query-planner/src/test/java/org/apache/pinot/query/QueryEnvironmentTestBase.java
index 3b0b811928..685252bbbe 100644
--- 
a/pinot-query-planner/src/test/java/org/apache/pinot/query/QueryEnvironmentTestBase.java
+++ 
b/pinot-query-planner/src/test/java/org/apache/pinot/query/QueryEnvironmentTestBase.java
@@ -250,6 +250,9 @@ public class QueryEnvironmentTestBase {
         new Object[]{"SELECT JSON_EXTRACT_SCALAR(col1, '$.foo', 'FLOAT_ARRAY') 
FROM a"},
         new Object[]{"SELECT JSON_EXTRACT_SCALAR(col1, '$.foo', 
'DOUBLE_ARRAY') FROM a"},
         new Object[]{"SELECT JSON_EXTRACT_SCALAR(col1, '$.foo', 
'STRING_ARRAY') FROM a"},
+        new Object[]{"SELECT ts_timestamp FROM a WHERE ts_timestamp BETWEEN 
TIMESTAMP '2016-01-01 00:00:00' AND "
+            + "TIMESTAMP '2016-01-01 10:00:00'"},
+        new Object[]{"SELECT ts_timestamp FROM a WHERE ts_timestamp >= 
CAST(1454284798000 AS TIMESTAMP)"}
     };
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to