Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
zclllyybb committed Jul 15, 2024
1 parent 2c2dd32 commit 5693cb4
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private static LocalDateTime getDateCeilOrFloor(DATE tag, LocalDateTime date, in
+ (dt.getHour() - start.getHour()) * 60 * 60
+ (dt.getMinute() - start.getMinute()) * 60
+ (dt.getSecond() - start.getSecond());
trivialPart = 0;
trivialPart = dt.getMicroSecond() - start.getMicroSecond();
break;
}
default: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public DateTimeV2Literal roundFloor(int newScale) {
}

public static Expression fromJavaDateType(LocalDateTime dateTime) {
return fromJavaDateType(dateTime, 0);
return fromJavaDateType(dateTime, 6);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.apache.doris.nereids.trees.expressions.functions.executable.DateTimeArithmetic;
import org.apache.doris.nereids.trees.expressions.functions.executable.DateTimeExtractAndTransform;
import org.apache.doris.nereids.trees.expressions.functions.scalar.AppendTrailingCharIfAbsent;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ConvertTz;
import org.apache.doris.nereids.trees.expressions.functions.scalar.DateFormat;
import org.apache.doris.nereids.trees.expressions.functions.scalar.DateTrunc;
import org.apache.doris.nereids.trees.expressions.functions.scalar.FromUnixtime;
Expand Down Expand Up @@ -183,14 +182,10 @@ void testFoldString() {
executor = new ExpressionRuleExecutor(ImmutableList.of(
bottomUp(FoldConstantRuleOnFE.VISITOR_INSTANCE)
));
ConvertTz c = new ConvertTz(DateTimeV2Literal.fromJavaDateType(LocalDateTime.of(1, 1, 1, 1, 1, 1)),
StringLiteral.of("Asia/Shanghai"), StringLiteral.of("GMT"));
Expression rewritten = executor.rewrite(c, context);
Assertions.assertEquals(new DateTimeV2Literal("0000-12-31 16:55:18"), rewritten);

DateFormat d = new DateFormat(DateTimeLiteral.fromJavaDateType(LocalDateTime.of(1, 1, 1, 1, 1, 1)),
StringLiteral.of("%y %m %d"));
rewritten = executor.rewrite(d, context);
Expression rewritten = executor.rewrite(d, context);
Assertions.assertEquals(new VarcharLiteral("01 01 01"), rewritten);
d = new DateFormat(DateTimeV2Literal.fromJavaDateType(LocalDateTime.of(1, 1, 1, 1, 1, 1)),
StringLiteral.of("%y %m %d"));
Expand All @@ -212,7 +207,7 @@ void testFoldString() {
t = new DateTrunc(DateTimeV2Literal.fromJavaDateType(LocalDateTime.of(1, 1, 1, 1, 1, 1)),
StringLiteral.of("week"));
rewritten = executor.rewrite(t, context);
Assertions.assertEquals(new DateTimeV2Literal("0001-01-01 00:00:00"), rewritten);
Assertions.assertTrue(((Literal) rewritten).compareTo(new DateTimeV2Literal("0001-01-01 00:00:00.000000")) == 0);
t = new DateTrunc(DateLiteral.fromJavaDateType(LocalDateTime.of(1, 1, 1, 1, 1, 1)),
StringLiteral.of("week"));
rewritten = executor.rewrite(t, context);
Expand Down Expand Up @@ -632,9 +627,10 @@ void testDateTrunc() {
String[] tags = {"year", "month", "day", "hour", "minute", "second"};

String[] answer = {
"'2001-01-01 00:00:00'", "'2001-01-01 00:00:00'", "'2001-12-01 00:00:00'", "'2001-12-01 00:00:00'",
"'2001-12-31 00:00:00'", "'2001-12-31 00:00:00'", "'2001-12-31 01:00:00'", "'2001-12-31 01:00:00'",
"'2001-12-31 01:01:00'", "'2001-12-31 01:01:00'", "'2001-12-31 01:01:01'", "'2001-12-31 01:01:01'",
"'2001-01-01 00:00:00'", "'2001-01-01 00:00:00.000000'", "'2001-12-01 00:00:00'",
"'2001-12-01 00:00:00.000000'", "'2001-12-31 00:00:00'", "'2001-12-31 00:00:00.000000'",
"'2001-12-31 01:00:00'", "'2001-12-31 01:00:00.000000'", "'2001-12-31 01:01:00'",
"'2001-12-31 01:01:00.000000'", "'2001-12-31 01:01:01'", "'2001-12-31 01:01:01.000000'",
"'2001-01-01 00:00:00'", "'2001-01-01 00:00:00'", "'2001-01-01 00:00:00'",
"'2001-04-01 00:00:00'", "'2001-04-01 00:00:00'", "'2001-04-01 00:00:00'",
"'2001-07-01 00:00:00'", "'2001-07-01 00:00:00'", "'2001-07-01 00:00:00'",
Expand Down
16 changes: 8 additions & 8 deletions regression-test/conf/regression-conf.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ defaultDb = "regression_test"
// init cmd like: select @@session.tx_read_only
// at each time we connect.
// add allowLoadLocalInfile so that the jdbc can execute mysql load data from client.
jdbcUrl = "jdbc:mysql://127.0.0.1:9030/?useLocalSessionState=true&allowLoadLocalInfile=true"
targetJdbcUrl = "jdbc:mysql://127.0.0.1:9030/?useLocalSessionState=true&allowLoadLocalInfile=true"
jdbcUrl = "jdbc:mysql://127.0.0.1:9737/?useLocalSessionState=true&allowLoadLocalInfile=true"
targetJdbcUrl = "jdbc:mysql://127.0.0.1:9737/?useLocalSessionState=true&allowLoadLocalInfile=true"
jdbcUser = "root"
jdbcPassword = ""

feSourceThriftAddress = "127.0.0.1:9020"
feTargetThriftAddress = "127.0.0.1:9020"
syncerAddress = "127.0.0.1:9190"
feSourceThriftAddress = "127.0.0.1:9727"
feTargetThriftAddress = "127.0.0.1:9727"
syncerAddress = "127.0.0.1:9897"
feSyncerUser = "root"
feSyncerPassword = ""

feHttpAddress = "127.0.0.1:8030"
feHttpAddress = "127.0.0.1:8737"
feHttpUser = "root"
feHttpPassword = ""

Expand Down Expand Up @@ -104,8 +104,8 @@ brokerName = "broker_name"

// broker load test config
enableBrokerLoad=true
ak=""
sk=""
ak="AKIDAE2aqpY0B7oFPIvHMBj01lFSO3RYOxFH"
sk="nJYWDepkQqzrWv3uWsxlJ0ScV7SXLs88"

// jdbc connector test config
// To enable jdbc test, you need first start mysql/pg container.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ suite("nereids_test_alias_function") {

test {
sql 'select cast(f1(\'2023-06-01\', 3) as string);'
result([['2023-05-29 00:00:00']])
result([['2023-05-29 00:00:00.000000']])
}
test {
sql 'select f2(f1(\'2023-05-20\', 2), 3)'
Expand Down
4 changes: 2 additions & 2 deletions regression-test/suites/nereids_p0/test_user_var.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ suite("test_user_var") {

explain {
sql("shape plan select * from dwd_login_ttt_view where day='2024-04-01';")
contains "dt < '2024-02-01 16:00:00'"
contains "dt >= '2024-01-31 16:00:00'"
contains "cast(dt as DATETIMEV2(6)) < convert_tz('2024-02-02 00:00:00.000000', 'Asia/Shanghai', 'GMT')"
contains "cast(dt as DATETIMEV2(6)) >= convert_tz('2024-02-01 00:00:00.000000', 'Asia/Shanghai', 'GMT')"
}
}

0 comments on commit 5693cb4

Please sign in to comment.