Skip to content

Commit

Permalink
add comment in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bobhan1 committed Nov 12, 2023
1 parent 656158d commit 2630e83
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ public List<Rule> buildRules() {
boolean needExtraSeqCol = isPartialUpdate && !childHasSeqCol && table.hasSequenceCol()
&& table.getSequenceMapCol() != null
&& sink.getColNames().contains(table.getSequenceMapCol());
Pair<List<Column>, Integer> bindColumnsReult =
Pair<List<Column>, Integer> bindColumnsResult =
bindTargetColumns(table, sink.getColNames(), childHasSeqCol, needExtraSeqCol);
List<Column> bindColumns = bindColumnsReult.first;
int extraColumnsNum = bindColumnsReult.second;
List<Column> bindColumns = bindColumnsResult.first;
int extraColumnsNum = bindColumnsResult.second;

LogicalOlapTableSink<?> boundSink = new LogicalOlapTableSink<>(
database,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@
3

-- !5 --
2
3

Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ suite("nereids_update_on_current_timestamp") {
(2, "doris2", 2000, 223, 1),
(1, "doris", 1000, 123, 1);"""
qt_sql "select id,name,score,test,dft from ${t1} order by id;"
qt_1 "select count(distinct update_time) from ${t1} where update_time > '2023-10-01 00:00:00';"
qt_1 "select count(distinct update_time2) from ${t1} where update_time2 > '2023-10-01 00:00:00';"
// rows with id=1 or id=2 will have the same value 't1' in `update_time` and `update_time2`
qt_1 "select count(distinct update_time) from ${t1} where update_time > '2023-10-01 00:00:00';" // 1
qt_1 "select count(distinct update_time2) from ${t1} where update_time2 > '2023-10-01 00:00:00';" // 1
sleep(2000)


Expand All @@ -66,29 +67,36 @@ suite("nereids_update_on_current_timestamp") {
(3, 3999),
(4, 4999);"""
qt_2 "select id,name,score,test,dft from ${t1} order by id;"
qt_2 "select count(distinct update_time) from ${t1} where update_time > '2023-10-01 00:00:00';"
qt_2 "select count(distinct update_time2) from ${t1} where update_time2 > '2023-10-01 00:00:00';"
// the existing rows(id=1,2) and newly inserted rows(id=3,4) are updated at the same time
// so they will have the same value 't1 + 2000ms' in `update_time` and `update_time2`
qt_2 "select count(distinct update_time) from ${t1} where update_time > '2023-10-01 00:00:00';" // 1
qt_2 "select count(distinct update_time2) from ${t1} where update_time2 > '2023-10-01 00:00:00';" // 1
sleep(2000)

// when user specify that column, it will be filled with the input value
sql """ insert into ${t1}(id, update_time) values
(1, "2000-01-01 00:00:01"),
(2, "2000-01-02 00:00:01");"""
qt_3 "select id,name,score,test,dft from ${t1} order by id;"
qt_3 "select count(distinct update_time) from ${t1} where update_time > '2023-10-01 00:00:00';"
qt_3 "select count(distinct update_time) from ${t1};"
qt_3 "select count(distinct update_time2) from ${t1} where update_time2 > '2023-10-01 00:00:00';"
// rows with id=1,2 are updated, the value of `update_time2` will be updated to `t1 + 4000ms`
qt_3 "select count(distinct update_time) from ${t1} where update_time > '2023-10-01 00:00:00';" // 1
qt_3 "select count(distinct update_time) from ${t1};" // 3 := (1)(2)(3,4)
qt_3 "select count(distinct update_time2) from ${t1} where update_time2 > '2023-10-01 00:00:00';" // 2 := (1,2)(3,4)
sleep(2000)

// test update statement
sql """ update ${t1} set score = score * 2 where id < 3;"""
// rows with id=1,2 are updated, the value of `update_time`, `update_time2` will be updated to `t1 + 6000ms`
qt_4 "select id,name,score,test,dft from ${t1} order by id;"
qt_4 "select count(distinct update_time) from ${t1} where update_time > '2023-10-01 00:00:00';"
qt_4 "select count(distinct update_time2) from ${t1} where update_time2 > '2023-10-01 00:00:00';"
qt_4 "select count(distinct update_time) from ${t1} where update_time > '2023-10-01 00:00:00';" // 2 := (1,2)(3,4)
qt_4 "select count(distinct update_time2) from ${t1} where update_time2 > '2023-10-01 00:00:00';" // 2 := (1,2)(3,4)
sleep(2000)

sql """ update ${t1} set update_time = "2023-10-02 00:00:00" where id > 3;"""
// rows with id=4 are updated, the value of `update_time`, `update_time2` will be updated to `t1 + 8000ms`
qt_5 "select id,name,score,test,dft from ${t1} order by id;"
qt_5 "select count(distinct update_time) from ${t1} where update_time > '2023-10-01 00:00:00';"
qt_5 "select count(distinct update_time2) from ${t1} where update_time2 > '2023-10-01 00:00:00';"
qt_5 "select count(distinct update_time) from ${t1} where update_time > '2023-10-01 00:00:00';" // 3 := (1,2)(3)(4)
qt_5 "select count(distinct update_time2) from ${t1} where update_time2 > '2023-10-01 00:00:00';" // 3 := (1,2)(3)(4)

// illegal case 1: the default value is not current_timestamp
def illegal_t1 = "nereids_update_on_current_timestamp_illegal_1"
Expand Down

0 comments on commit 2630e83

Please sign in to comment.