Skip to content

Commit

Permalink
[BugFix] fix partial update column name sensitive issue (StarRocks#55430
Browse files Browse the repository at this point in the history
)

Signed-off-by: luohaha <18810541851@163.com>
  • Loading branch information
luohaha authored Jan 26, 2025
1 parent 2d41b74 commit ab228aa
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fe/fe-core/src/main/java/com/starrocks/load/Load.java
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,9 @@ public static void initColumns(Table tbl, List<ImportColumnDesc> columnExprs,

public static List<Column> getPartialUpateColumns(Table tbl, List<ImportColumnDesc> columnExprs,
List<Boolean> missAutoIncrementColumn) throws StarRocksException {
Set<String> specified = columnExprs.stream().map(desc -> desc.getColumnName()).collect(Collectors.toSet());
Set<String> specified = columnExprs.stream()
.map(desc -> desc.getColumnName())
.collect(Collectors.toCollection(() -> Sets.newTreeSet(String.CASE_INSENSITIVE_ORDER)));
List<Column> ret = new ArrayList<>();
for (Column col : tbl.getBaseSchema()) {
if (specified.contains(col.getName())) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1,"xx"
51 changes: 51 additions & 0 deletions test/sql/test_stream_load/R/test_partial_update_case_sensitive
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
-- name: test_partial_update_case_sensitive
create database test_partial_update_case_sensitive;
-- result:
-- !result
use test_partial_update_case_sensitive;
-- result:
-- !result
CREATE TABLE test1 (
`id` bigint(20) NOT NULL COMMENT "",
`name` char(16) NULL DEFAULT "" COMMENT "",
`city` char(16) NULL DEFAULT "" COMMENT "",
`age` char(24) NULL DEFAULT "" COMMENT ""
) ENGINE=OLAP
PRIMARY KEY(`id`)
DISTRIBUTED BY HASH(`id`)
PROPERTIES (
"replication_num" = "1",
"in_memory" = "false",
"storage_format" = "DEFAULT",
"enable_persistent_index" = "true",
"compression" = "LZ4"
);
-- result:
-- !result
insert into test_partial_update_case_sensitive.test1 values(1,'name1','SD',5),(2,'name2','SH',25),(3,'name3','BJ',50);
-- result:
-- !result
shell: curl --location-trusted -u root: -X PUT -H "Expect:100-continue" -H "format: csv" -H "partial_update: true" -H "columns: ID, city" -H column_separator:, -T ${root_path}/lib/../common/data/stream_load/test_partial_update_case_sensitive.csv ${url}/api/test_partial_update_case_sensitive/test1/_stream_load
-- result:
0
{
"Status": "Success",
"Message": "OK"
}
-- !result
sync;
-- result:
-- !result
select * from test_partial_update_case_sensitive.test1;
-- result:
2 name2 SH 25
1 name1 "xx" 5
3 name3 BJ 50
-- !result
select * from test_partial_update_case_sensitive.test1 where name = "name1";
-- result:
1 name1 "xx" 5
-- !result
drop database test_partial_update_case_sensitive force;
-- result:
-- !result
27 changes: 27 additions & 0 deletions test/sql/test_stream_load/T/test_partial_update_case_sensitive
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-- name: test_partial_update_case_sensitive
create database test_partial_update_case_sensitive;
use test_partial_update_case_sensitive;
CREATE TABLE test1 (
`id` bigint(20) NOT NULL COMMENT "",
`name` char(16) NULL DEFAULT "" COMMENT "",
`city` char(16) NULL DEFAULT "" COMMENT "",
`age` char(24) NULL DEFAULT "" COMMENT ""
) ENGINE=OLAP
PRIMARY KEY(`id`)
DISTRIBUTED BY HASH(`id`)
PROPERTIES (
"replication_num" = "1",
"in_memory" = "false",
"storage_format" = "DEFAULT",
"enable_persistent_index" = "true",
"compression" = "LZ4"
);

insert into test_partial_update_case_sensitive.test1 values(1,'name1','SD',5),(2,'name2','SH',25),(3,'name3','BJ',50);
shell: curl --location-trusted -u root: -X PUT -H "Expect:100-continue" -H "format: csv" -H "partial_update: true" -H "columns: ID, city" -H column_separator:, -T ${root_path}/lib/../common/data/stream_load/test_partial_update_case_sensitive.csv ${url}/api/test_partial_update_case_sensitive/test1/_stream_load
sync;

select * from test_partial_update_case_sensitive.test1;
select * from test_partial_update_case_sensitive.test1 where name = "name1";

drop database test_partial_update_case_sensitive force;

0 comments on commit ab228aa

Please sign in to comment.