Skip to content

Commit

Permalink
change by comment
Browse files Browse the repository at this point in the history
  • Loading branch information
feiniaofeiafei committed Dec 17, 2024
1 parent 34693be commit 62b72ba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public class DateFormat extends ScalarFunction
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DateType.INSTANCE, VarcharType.SYSTEM_DEFAULT)
);

private static final Set<String> monoFormat = ImmutableSet.of("yyyyMMdd", "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss",
"%Y", "%Y-%m", "%Y-%m-%d", "%Y-%m-%d%H", "%Y-%m-%d%H:%i", "%Y-%m-%d%H:%i:%s", "%Y-%m-%d%H:%i:%S",
"%Y-%m-%d%T", "%Y%m%d", "%Y%m");

/**
* constructor with 2 arguments.
*/
Expand Down Expand Up @@ -86,10 +90,7 @@ public boolean isMonotonic() {
return false;
}
VarcharLiteral varcharLiteral = (VarcharLiteral) format;
String str = varcharLiteral.getValue();
Set<String> monoFormat = ImmutableSet.of("yyyyMMdd", "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "%Y", "%Y-%m",
"%Y-%m-%d", "%Y-%m-%d %H", "%Y-%m-%d %H:%i", "%Y-%m-%d %H:%i:%s", "%Y-%m-%d %H:%i:%S", "%Y-%m-%d %T",
"%Y%m%d", "%Y%m");
String str = varcharLiteral.getValue().replace(" ", "");
return monoFormat.contains(str);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ suite("always_mono_func") {
sql """select * from always_mono_func where date_format(dt, "%Y%m") > "20190101" """
contains("partitions=2/5 (p4,p5)")
}

explain {
sql """select * from always_mono_func where date_format(dt, "%Y %m") > "2019 01" """
contains("partitions=2/5 (p4,p5)")
}

explain {
sql """ select * from always_mono_func where last_day(dt) > "2019-01-01" """
Expand Down

0 comments on commit 62b72ba

Please sign in to comment.