Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bobhan1 committed Oct 17, 2023
1 parent 24c54d7 commit f3456cc
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.apache.doris.nereids.trees.expressions.literal.NullLiteral;
import org.apache.doris.nereids.trees.expressions.visitor.DefaultExpressionRewriter;
import org.apache.doris.nereids.trees.plans.Plan;
import org.apache.doris.nereids.trees.plans.commands.info.DefaultValue;
import org.apache.doris.nereids.trees.plans.logical.LogicalOlapTableSink;
import org.apache.doris.nereids.trees.plans.logical.LogicalPlan;
import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
Expand Down Expand Up @@ -108,11 +109,15 @@ public List<Rule> buildRules() {
}

try {
if (table.hasSequenceCol() && table.getSequenceMapCol() != null && !boundSink.isPartialUpdate()) {
if (table.hasSequenceCol() && table.getSequenceMapCol() != null
&& !sink.getColNames().isEmpty() && !boundSink.isPartialUpdate()) {
Column seqCol = table.getFullSchema().stream()
.filter(col -> col.getName().equals(table.getSequenceMapCol()))
.findFirst().get();
if (seqCol.getDefaultValue() == null
Optional<String> foundCol = sink.getColNames().stream()
.filter(col -> col.equals(table.getSequenceMapCol()))
.findFirst();
if (!foundCol.isPresent() && seqCol.getDefaultValue() == null
|| !seqCol.getDefaultValue().equals(DefaultValue.CURRENT_TIMESTAMP)) {
throw new AnalysisException("Table " + table.getName()
+ " has sequence column, need to specify the sequence column");
Expand Down
30 changes: 24 additions & 6 deletions regression-test/conf/regression-conf.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +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:9134/?useLocalSessionState=true&allowLoadLocalInfile=true"
targetJdbcUrl = "jdbc:mysql://127.0.0.1:9134/?useLocalSessionState=true&allowLoadLocalInfile=true"
jdbcUrl = "jdbc:mysql://127.0.0.1:9030/?useLocalSessionState=true&allowLoadLocalInfile=true"
targetJdbcUrl = "jdbc:mysql://127.0.0.1:9030/?useLocalSessionState=true&allowLoadLocalInfile=true"
jdbcUser = "root"
jdbcPassword = ""

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

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

Expand All @@ -46,6 +47,24 @@ pluginPath = "${DORIS_HOME}/regression-test/plugins"
realDataPath = "${DORIS_HOME}/regression-test/realdata"
sslCertificatePath = "${DORIS_HOME}/regression-test/ssl_default_certificate"

// suite configs
suites = {

//// equals to:
//// suites.test_suite_1.key1 = "val1"
//// suites.test_suite_1.key2 = "val2"
////
//test_suite_1 {
// key1 = "val1"
// key2 = "val2"
//}

//test_suite_2 {
// key3 = "val1"
// key4 = "val2"
//}
}

// docker image
image = ""
dockerEndDeleteFiles = false
Expand Down Expand Up @@ -161,4 +180,3 @@ max_failure_num=0
s3ExportBucketName = ""

externalEnvIp="127.0.0.1"

Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@
2 doris2 2600 223 1 2023-07-20 0 4 2023-07-20
3 unknown 2500 \N 4321 2022-07-18 0 4 2022-07-18

-- !sql --
1 200 2023-10-17T11:45:08 0 2 2023-10-17T11:45:08
2 400 2023-10-17T11:45:08 0 2 2023-10-17T11:45:08

Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
1 doris 200 123 1 2023-01-01 0 3 2023-01-01
2 doris2 2600 223 1 2023-07-20 0 4 2023-07-20
3 unknown 1500 \N 4321 2022-07-20 0 4 2022-07-20

Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ suite("nereids_partial_update_native_insert_seq_col", "p0") {

qt_select_default """ select * from ${tableName} order by id;"""

// don't set partial update header, it's a row update streamload
// the input data don't contains sequence mapping column, will load fail
// set enable_unique_key_partial_update=false, it's a row update
// the input data don't contains sequence mapping column and the sequence mapping
// column's default value is not CURRENT_TIMESTAMP, will load fail
test {
sql "insert into ${tableName}(id,score) values(2,400),(1,200);"
exception "Table nereids_partial_update_native_insert_seq_col has sequence column, need to specify the sequence column"
}

// set partial update header, should success
// set enable_unique_key_partial_update=true, should success
// we don't provide the sequence column in input data, so the updated rows
// should use there original sequence column values.
sql "set enable_unique_key_partial_update=true;"
Expand Down Expand Up @@ -86,4 +87,28 @@ suite("nereids_partial_update_native_insert_seq_col", "p0") {
qt_partial_update_with_seq_hidden_columns """select * from ${tableName} order by id;"""

sql """ DROP TABLE IF EXISTS ${tableName} """


def tableName2 = "nereids_partial_update_native_insert_seq_col2"
sql """ DROP TABLE IF EXISTS ${tableName2} """
sql """
CREATE TABLE ${tableName2} (
`id` int(11) NOT NULL COMMENT "用户 ID",
`score` int(11) NOT NULL COMMENT "用户得分",
`update_time` DATETIMEV2 NULL DEFAULT CURRENT_TIMESTAMP)
UNIQUE KEY(`id`) DISTRIBUTED BY HASH(`id`) BUCKETS 1
PROPERTIES(
"replication_num" = "1",
"enable_unique_key_merge_on_write" = "true",
"function_column.sequence_col" = "update_time"
)"""

// don't set enable_unique_key_partial_update, it's a row update
// the input data don't contains sequence mapping column but the sequence mapping
// column's default value is CURRENT_TIMESTAMP, will load successfully
sql "set enable_unique_key_partial_update=false;"
sql "sync;"
sql "insert into ${tableName2}(id,score) values(2,400),(1,200);"
qt_sql """ select * from ${tableName2} order by id;"""
sql """ DROP TABLE IF EXISTS ${tableName2}; """
}

0 comments on commit f3456cc

Please sign in to comment.