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

libenchao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/main by this push:
     new e3b5028223 [CALCITE-6030] DATE_PART is not handled by the 
RexToLixTranslator
e3b5028223 is described below

commit e3b5028223d82e2432d037d56d2cee1315a6d7ab
Author: Mihai Budiu <[email protected]>
AuthorDate: Mon Oct 16 13:45:03 2023 -0700

    [CALCITE-6030] DATE_PART is not handled by the RexToLixTranslator
    
    Signed-off-by: Mihai Budiu <[email protected]>
---
 babel/src/test/java/org/apache/calcite/test/BabelTest.java         | 7 +++++++
 .../java/org/apache/calcite/adapter/enumerable/RexImpTable.java    | 2 ++
 2 files changed, 9 insertions(+)

diff --git a/babel/src/test/java/org/apache/calcite/test/BabelTest.java 
b/babel/src/test/java/org/apache/calcite/test/BabelTest.java
index 42166a1d0d..1feb2e6020 100644
--- a/babel/src/test/java/org/apache/calcite/test/BabelTest.java
+++ b/babel/src/test/java/org/apache/calcite/test/BabelTest.java
@@ -232,6 +232,13 @@ class BabelTest {
         "EXPR$0=false\n");
   }
 
+  /** Test case for <a 
href="https://issues.apache.org/jira/browse/CALCITE-6030";>
+   * [CALCITE-6030] DATE_PART is not handled by the RexToLixTranslator</a>. */
+  @Test void testDatePart() {
+    checkSqlResult("postgresql", "SELECT DATE_PART(second, TIME '10:10:10')",
+        "EXPR$0=10\n");
+  }
+
   /** Test case for
    * <a 
href="https://issues.apache.org/jira/browse/CALCITE-5816";>[CALCITE-5816]
    * Query with LEFT SEMI JOIN should not refer to RHS columns</a>. */
diff --git 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
index 9d563077c8..b3a5565eb5 100644
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
+++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
@@ -169,6 +169,7 @@ import static 
org.apache.calcite.sql.fun.SqlLibraryOperators.DATEADD;
 import static org.apache.calcite.sql.fun.SqlLibraryOperators.DATETIME;
 import static org.apache.calcite.sql.fun.SqlLibraryOperators.DATETIME_TRUNC;
 import static 
org.apache.calcite.sql.fun.SqlLibraryOperators.DATE_FROM_UNIX_DATE;
+import static org.apache.calcite.sql.fun.SqlLibraryOperators.DATE_PART;
 import static org.apache.calcite.sql.fun.SqlLibraryOperators.DATE_TRUNC;
 import static org.apache.calcite.sql.fun.SqlLibraryOperators.DAYNAME;
 import static org.apache.calcite.sql.fun.SqlLibraryOperators.DIFFERENCE;
@@ -688,6 +689,7 @@ public class RexImpTable {
       map.put(DATETIME_PLUS, new DatetimeArithmeticImplementor());
       map.put(MINUS_DATE, new DatetimeArithmeticImplementor());
       map.put(EXTRACT, new ExtractImplementor());
+      map.put(DATE_PART, new ExtractImplementor());
       map.put(FLOOR,
           new FloorImplementor(BuiltInMethod.FLOOR.method,
               BuiltInMethod.UNIX_TIMESTAMP_FLOOR.method,

Reply via email to