bobhan1 commented on issue #24573:
URL: https://github.com/apache/doris/issues/24573#issuecomment-1728672315

   @yuxuan-luo 我本地测的没问题,ignore 
mode的含义是如果插入行的key在原表中存在,则不插入这一行,test2.csv中插入行的key在原表中均存在,所以test2.csv的内容都不会插入,期望结果应该是
   ```
   +------+-----------+------+------------+---------+
   | id   | name      | age  | city       | balance |
   +------+-----------+------+------------+---------+
   |    1 |           | NULL |            |    NULL |
   |    2 | "bob"     | NULL | "beijing"  |    5000 |
   |    3 |           | NULL |            |    6000 |
   |    4 |           | NULL | "hangzhou" |    NULL |
   |    5 | "tom"     | NULL |            |    NULL |
   |   10 |           |  280 | "shenzhen" |    1111 |
   |   20 | "leo"     |  300 |            |    2222 |
   |   30 | "sam"     |  320 | "shanghai" |    NULL |
   |   40 |           |  340 |            |    NULL |
   |   50 | "cynthia" |  360 | "guanzhou" |    8000 |
   |   11 |           | NULL |            |    NULL |
   |   12 |           |  280 | "shenzhen" |    1111 |
   |   14 | "leo"     |  300 |            |    2222 |
   |   15 | "sam"     |  320 | "shanghai" |    NULL |
   |   16 |           | NULL |            |    6000 |
   |   17 |           | NULL | "hangzhou" |    NULL |
   |   18 |           |  340 |            |    NULL |
   |   19 | "tom"     | NULL |            |    NULL |
   |  123 | "bob"     | NULL | "beijing"  |    5000 |
   |  201 | "cynthia" |  360 | "guanzhou" |    8000 |
   +------+-----------+------+------------+---------+
   ```
   
   测试过程:
   建表
   ```
   CREATE TABLE t1 (
   id int(11) NULL,
   name varchar(10) NULL,
   age int(11) NULL DEFAULT "20",
   city varchar(10) NOT NULL DEFAULT "beijing",
   balance DECIMAL NULL
   ) ENGINE=OLAP
   UNIQUE KEY(id)
   COMMENT 'OLAP'
   DISTRIBUTED BY HASH(id) BUCKETS 1
   PROPERTIES (
   "replication_allocation" = "tag.location.default: 1",
   "is_being_synced" = "false",
   "storage_format" = "V2",
   "enable_unique_key_merge_on_write" = "true",
   "light_schema_change" = "true",
   "disable_auto_compaction" = "false",
   "enable_single_replica_compaction" = "false"
   );
   ```
   第一次导入数据
   ```
   curl --location-trusted -u root: -H "column_separator:," -H 
"ignore_mode:true" -T ./test1.csv http://127.0.0.1:8134/api/demo/t1/_stream_load
   ```
   查询
   ```
   mysql> select * from t1;
   +------+-----------+------+------------+---------+
   | id   | name      | age  | city       | balance |
   +------+-----------+------+------------+---------+
   |    1 |           | NULL |            |    NULL |
   |    2 | "bob"     | NULL | "beijing"  |    5000 |
   |    3 |           | NULL |            |    6000 |
   |    4 |           | NULL | "hangzhou" |    NULL |
   |    5 | "tom"     | NULL |            |    NULL |
   |   10 |           |  280 | "shenzhen" |    1111 |
   |   20 | "leo"     |  300 |            |    2222 |
   |   30 | "sam"     |  320 | "shanghai" |    NULL |
   |   40 |           |  340 |            |    NULL |
   |   50 | "cynthia" |  360 | "guanzhou" |    8000 |
   +------+-----------+------+------------+---------+
   ```
   第二次导入数据
   ```
   curl --location-trusted -u root: -H "column_separator:," -H 
"ignore_mode:true" -T ./test2.csv http://127.0.0.1:8134/api/demo/t1/_stream_load
   ```
   查询
   ```
   mysql> select * from t1;
   +------+-----------+------+------------+---------+
   | id   | name      | age  | city       | balance |
   +------+-----------+------+------------+---------+
   |    1 |           | NULL |            |    NULL |
   |    2 | "bob"     | NULL | "beijing"  |    5000 |
   |    3 |           | NULL |            |    6000 |
   |    4 |           | NULL | "hangzhou" |    NULL |
   |    5 | "tom"     | NULL |            |    NULL |
   |   10 |           |  280 | "shenzhen" |    1111 |
   |   20 | "leo"     |  300 |            |    2222 |
   |   30 | "sam"     |  320 | "shanghai" |    NULL |
   |   40 |           |  340 |            |    NULL |
   |   50 | "cynthia" |  360 | "guanzhou" |    8000 |
   +------+-----------+------+------------+---------+
   ```
   第三次导入数据
   ```
   curl --location-trusted -u root: -H "column_separator:," -H 
"ignore_mode:true" -T ./test_in.csv 
http://127.0.0.1:8134/api/demo/t1/_stream_load
   ```
   查询
   ```
   mysql> select * from t1;
   +------+-----------+------+------------+---------+
   | id   | name      | age  | city       | balance |
   +------+-----------+------+------------+---------+
   |    1 |           | NULL |            |    NULL |
   |    2 | "bob"     | NULL | "beijing"  |    5000 |
   |    3 |           | NULL |            |    6000 |
   |    4 |           | NULL | "hangzhou" |    NULL |
   |    5 | "tom"     | NULL |            |    NULL |
   |   10 |           |  280 | "shenzhen" |    1111 |
   |   20 | "leo"     |  300 |            |    2222 |
   |   30 | "sam"     |  320 | "shanghai" |    NULL |
   |   40 |           |  340 |            |    NULL |
   |   50 | "cynthia" |  360 | "guanzhou" |    8000 |
   |   11 |           | NULL |            |    NULL |
   |   12 |           |  280 | "shenzhen" |    1111 |
   |   14 | "leo"     |  300 |            |    2222 |
   |   15 | "sam"     |  320 | "shanghai" |    NULL |
   |   16 |           | NULL |            |    6000 |
   |   17 |           | NULL | "hangzhou" |    NULL |
   |   18 |           |  340 |            |    NULL |
   |   19 | "tom"     | NULL |            |    NULL |
   |  123 | "bob"     | NULL | "beijing"  |    5000 |
   |  201 | "cynthia" |  360 | "guanzhou" |    8000 |
   +------+-----------+------+------------+---------+
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to