Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select_default --
1 doris 1000 123 1 2023-01-01
2 doris2 2000 223 1 2023-01-01

-- !partial_update_without_seq --

-- !partial_update_with_seq --

-- !partial_update_with_seq_hidden_columns --
1 unknown 1300 \N 4321 2022-07-19 1 4 2022-07-19
2 unknown 2600 \N 4321 2023-07-20 1 4 2023-07-20
3 unknown 1500 \N 4321 2022-07-20 1 4 2022-07-20

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select_default --
1 doris 1000 123 1 2023-01-01
2 doris2 2000 223 1 2023-01-01

-- !partial_update_with_seq_score --

-- !partial_update_with_seq_score_hidden --
1 unknown 2300 2300 4321 2021-05-19 1 3 2300
2 unknown 3600 2400 4321 2019-01-23 1 3 3600
3 unknown 2000 2400 4321 2022-02-18 1 3 2000

-- !partial_update_with_seq_test --

-- !partial_update_with_seq_test_hidden --
1 unknown 2300 2300 4321 2021-05-19 1 4 2300
2 unknown 3600 2400 4321 2019-01-23 1 3 3600
3 unknown 1500 2500 4321 2022-03-31 1 4 2500

-- !select_no_partial_update_score --
1 unknown 2300 2350 4321 2021-05-18 1 5 2300
2 unknown 3650 2450 4321 2019-01-22 1 5 3650
3 unknown 1500 2500 4321 2022-03-31 1 4 2500

-- !select_no_partial_update_test --
1 unknown 2300 2350 4321 2021-05-18 1 6 2350
2 unknown 3650 2450 4321 2019-01-22 1 5 3650
3 unknown 1550 2550 4321 2022-03-30 1 6 2550

Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@

// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

suite("test_primary_key_partial_update_seq_col_delete", "p0") {
def tableName = "test_primary_key_partial_update_seq_col_delete"

// create table
sql """ DROP TABLE IF EXISTS ${tableName} """
sql """
CREATE TABLE ${tableName} (
`id` int(11) NOT NULL COMMENT "用户 ID",
`name` varchar(65533) DEFAULT "unknown" COMMENT "用户姓名",
`score` int(11) NOT NULL COMMENT "用户得分",
`test` int(11) NULL COMMENT "null test",
`dft` int(11) DEFAULT "4321",
`update_time` date NULL)
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"
)
"""
// insert 2 lines
sql """
insert into ${tableName} values
(2, "doris2", 2000, 223, 1, '2023-01-01'),
(1, "doris", 1000, 123, 1, '2023-01-01')
"""

sql "sync"

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

// set partial update header, should success
// we don't provide the sequence column in input data, so the updated rows
// should use there original sequence column values.
streamLoad {
table "${tableName}"

set 'column_separator', ','
set 'format', 'csv'
set 'partial_columns', 'true'
set 'columns', 'id,score'
set 'merge_type', 'DELETE'

file 'basic.csv'
time 10000 // limit inflight 10s
}

sql "sync"

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

// provide the sequence column this time, should update according to the
// given sequence values
streamLoad {
table "${tableName}"

set 'column_separator', ','
set 'format', 'csv'
set 'partial_columns', 'true'
set 'columns', 'id,score,update_time'
set 'merge_type', 'DELETE'

file 'basic_with_seq.csv'
time 10000 // limit inflight 10s
}

sql "sync"

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

sql "SET show_hidden_columns=true"

sql "sync"

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

// drop drop
sql """ DROP TABLE IF EXISTS ${tableName} """
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@

// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

suite("test_primary_key_partial_update_seq_type_delete", "p0") {
def tableName = "test_primary_key_partial_update_seq_type_delete"

// create table
sql """ DROP TABLE IF EXISTS ${tableName} """
sql """
CREATE TABLE ${tableName} (
`id` int(11) NOT NULL COMMENT "用户 ID",
`name` varchar(65533) DEFAULT "unknown" COMMENT "用户姓名",
`score` int(11) NOT NULL COMMENT "用户得分",
`test` int(11) NULL COMMENT "null test",
`dft` int(11) DEFAULT "4321",
`update_time` date NULL)
UNIQUE KEY(`id`) DISTRIBUTED BY HASH(`id`) BUCKETS 1
PROPERTIES(
"replication_num" = "1",
"enable_unique_key_merge_on_write" = "true",
"function_column.sequence_type" = "int"
)
"""
// insert 2 lines
sql """
insert into ${tableName} values
(2, "doris2", 2000, 223, 1, '2023-01-01'),
(1, "doris", 1000, 123, 1, '2023-01-01')
"""

sql "sync"

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

// no sequence column header, stream load should fail
streamLoad {
table "${tableName}"

set 'column_separator', ','
set 'format', 'csv'
set 'partial_columns', 'true'
set 'columns', 'id,score,test,update_time'
set 'merge_type', 'DELETE'

file 'basic_with_test.csv'
time 10000 // limit inflight 10s

check { result, exception, startTime, endTime ->
if (exception != null) {
throw exception
}
log.info("Stream load result: ${result}".toString())
def json = parseJson(result)
assertEquals("fail", json.Status.toLowerCase())
assertTrue(json.Message.contains('need to specify the sequence column'))
}
}

sql "sync"

// both partial_columns and sequence column header, stream load should success
streamLoad {
table "${tableName}"

set 'column_separator', ','
set 'format', 'csv'
set 'partial_columns', 'true'
set 'columns', 'id,score,test,update_time'
set 'function_column.sequence_col', 'score'
set 'merge_type', 'DELETE'

file 'basic_with_test.csv'
time 10000 // limit inflight 10s
}

sql "sync"

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

sql "SET show_hidden_columns=true"

sql "sync"

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

// use test as sequence column
streamLoad {
table "${tableName}"

set 'column_separator', ','
set 'format', 'csv'
set 'partial_columns', 'true'
set 'columns', 'id,score,test,update_time'
set 'function_column.sequence_col', 'test'
set 'merge_type', 'DELETE'

file 'basic_with_test.csv'
time 10000 // limit inflight 10s
}

sql "SET show_hidden_columns=false"

sql "sync"

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

sql "SET show_hidden_columns=true"

sql "sync"

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

// no partial update header, stream load should success,
// but the missing columns will be filled with default values
streamLoad {
table "${tableName}"

set 'column_separator', ','
set 'format', 'csv'
set 'columns', 'id,score,test,update_time'
set 'function_column.sequence_col', 'score'
set 'merge_type', 'DELETE'

file 'basic_with_test2.csv'
time 10000 // limit inflight 10s
}

sql "sync"

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

// no partial update header, stream load should success,
// but the missing columns will be filled with default values
streamLoad {
table "${tableName}"

set 'column_separator', ','
set 'format', 'csv'
set 'columns', 'id,score,test,update_time'
set 'function_column.sequence_col', 'test'
set 'merge_type', 'DELETE'

file 'basic_with_test2.csv'
time 10000 // limit inflight 10s
}

sql "sync"

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

// drop table
sql """ DROP TABLE IF EXISTS ${tableName} """
}