Skip to content

Commit

Permalink
Support jodatime_fata function to partition pruning
Browse files Browse the repository at this point in the history
Signed-off-by: zhiminr.ren <[email protected]>
  • Loading branch information
renzhimin7 authored and trueeyu committed Nov 7, 2024
1 parent 335bfe4 commit 237bc03
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
*/
public class ScalarOperatorFunctions {
public static final Set<String> SUPPORT_JAVA_STYLE_DATETIME_FORMATTER =
ImmutableSet.<String>builder().add("yyyy-MM-dd").add("yyyy-MM-dd HH:mm:ss").add("yyyyMMdd").build();
ImmutableSet.<String>builder().add("yyyy-MM-dd").add("yyyy-MM-dd HH:mm:ss").add("yyyyMMdd").
add("yyyyMMdd HH:mm:ss").build();

private static final int CONSTANT_128 = 128;
private static final BigInteger INT_128_OPENER = BigInteger.ONE.shiftLeft(CONSTANT_128 + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@ public void testDateFnTransform() throws Exception {
assertPlanContains(sql, "week_iso('2023-01-01 00:00:00')");

sql = "select format_datetime(TIMESTAMP '2023-06-25 11:10:20', 'yyyyMMdd HH:mm:ss')";
assertPlanContains(sql, "jodatime_format('2023-06-25 11:10:20', 'yyyyMMdd HH:mm:ss')");
assertPlanContains(sql, "20230625 11:10:20");

sql = "select format_datetime(date '2023-06-25', 'yyyyMMdd HH:mm:ss');";
assertPlanContains(sql, "jodatime_format('2023-06-25', 'yyyyMMdd HH:mm:ss')");
assertPlanContains(sql, "20230625 00:00:00");

sql = "select to_char(TIMESTAMP '2023-06-25 11:10:20', 'yyyyMMdd HH:mm:ss');";
assertPlanContains(sql, "jodatime_format('2023-06-25 11:10:20', 'yyyyMMdd HH:mm:ss')");
assertPlanContains(sql, "20230625 11:10:20");

sql = "select parse_datetime('2023-08-02 14:37:02', 'yyyy-MM-dd HH:mm:ss')";
assertPlanContains(sql, "str_to_jodatime('2023-08-02 14:37:02', 'yyyy-MM-dd HH:mm:ss')");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public void dateFormat() {
ScalarOperatorFunctions.dateFormat(testDate, ConstantOperator.createVarchar("yyyy")).getVarchar());
assertEquals("20010109",
ScalarOperatorFunctions.dateFormat(testDate, ConstantOperator.createVarchar("yyyyMMdd")).getVarchar());
assertEquals("yyyyMMdd HH:mm:ss",
assertEquals("20010109 13:04:05",
ScalarOperatorFunctions.dateFormat(testDate, ConstantOperator.createVarchar("yyyyMMdd HH:mm:ss"))
.getVarchar());
assertEquals("HH:mm:ss",
Expand Down Expand Up @@ -1505,7 +1505,7 @@ public void testLowerUpper() {
@Test
public void testJodatimeFormat() {
assertEquals("20240806", ScalarOperatorFunctions.jodatimeFormat(
new ConstantOperator("2024-08-06", Type.DATE),
new ConstantOperator(LocalDateTime.parse("2024-08-06T12:30:45"), Type.DATE),
new ConstantOperator("yyyyMMdd", Type.VARCHAR)).getVarchar());
}

Expand Down

0 comments on commit 237bc03

Please sign in to comment.