Skip to content

Commit

Permalink
[CALCITE-6030] DATE_PART is not handled by the RexToLixTranslator
Browse files Browse the repository at this point in the history
Signed-off-by: Mihai Budiu <[email protected]>
  • Loading branch information
mihaibudiu authored and libenchao committed Oct 20, 2023
1 parent 23b7931 commit e3b5028
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions babel/src/test/java/org/apache/calcite/test/BabelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ private void checkInfixCast(Statement statement, String typeName, int sqlType)
"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>. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
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;
Expand Down Expand Up @@ -688,6 +689,7 @@ Builder populate2() {
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,
Expand Down

0 comments on commit e3b5028

Please sign in to comment.