This is an automated email from the ASF dual-hosted git repository.

kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 07aa865016b7198b684118e9851723df3f6f40b6
Author: bobhan1 <bh2444151...@outlook.com>
AuthorDate: Fri Jul 7 14:03:33 2023 +0800

    [fix](partial update) correct col_nums when init agg state in memtable 
(#21592)
---
 be/src/olap/memtable.cpp                           |  2 +-
 .../partial_update/basic_with_duplicate.csv        |  3 ++
 .../partial_update/basic_with_duplicate2.csv       |  6 ++++
 .../partial_update/test_partial_update.out         |  8 +++++
 .../partial_update/test_partial_update.groovy      | 37 ++++++++++++++++++++++
 5 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/be/src/olap/memtable.cpp b/be/src/olap/memtable.cpp
index 410d789721..76441a10bc 100644
--- a/be/src/olap/memtable.cpp
+++ b/be/src/olap/memtable.cpp
@@ -370,7 +370,7 @@ void MemTable::_aggregate() {
                 prev_row->init_agg_places(
                         _arena->aligned_alloc(_total_size_of_aggregate_states, 
16),
                         _offsets_of_aggregate_states.data());
-                for (auto cid = _schema->num_key_columns(); cid < 
_schema->num_columns(); cid++) {
+                for (auto cid = _tablet_schema->num_key_columns(); cid < 
_num_columns; cid++) {
                     auto col_ptr = mutable_block.mutable_columns()[cid].get();
                     auto data = prev_row->agg_places(cid);
                     _agg_functions[cid]->create(data);
diff --git 
a/regression-test/data/unique_with_mow_p0/partial_update/basic_with_duplicate.csv
 
b/regression-test/data/unique_with_mow_p0/partial_update/basic_with_duplicate.csv
new file mode 100644
index 0000000000..fe344a3366
--- /dev/null
+++ 
b/regression-test/data/unique_with_mow_p0/partial_update/basic_with_duplicate.csv
@@ -0,0 +1,3 @@
+2,555
+1,333
+1,444
\ No newline at end of file
diff --git 
a/regression-test/data/unique_with_mow_p0/partial_update/basic_with_duplicate2.csv
 
b/regression-test/data/unique_with_mow_p0/partial_update/basic_with_duplicate2.csv
new file mode 100644
index 0000000000..4b9b5e6b49
--- /dev/null
+++ 
b/regression-test/data/unique_with_mow_p0/partial_update/basic_with_duplicate2.csv
@@ -0,0 +1,6 @@
+2,888
+1,666
+2,999
+1,777
+1,1111
+2,2222
\ No newline at end of file
diff --git 
a/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update.out
 
b/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update.out
index bb14012688..e33f370a56 100644
--- 
a/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update.out
+++ 
b/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update.out
@@ -3,3 +3,11 @@
 1      doris   200     123     1
 2      doris2  400     223     1
 
+-- !partial_update_in_one_stream_load --
+1      doris   444     123     1
+2      doris2  555     223     1
+
+-- !partial_update_in_one_stream_load --
+1      doris   1111    123     1
+2      doris2  2222    223     1
+
diff --git 
a/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update.groovy
 
b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update.groovy
index 7bfcd75fc5..134b2d2bd0 100644
--- 
a/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update.groovy
+++ 
b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update.groovy
@@ -59,6 +59,43 @@ suite("test_primary_key_partial_update", "p0") {
         select * from ${tableName} order by id;
     """
 
+    // partial update a row multiple times in one stream load
+    streamLoad {
+        table "${tableName}"
+
+        set 'column_separator', ','
+        set 'format', 'csv'
+        set 'partial_columns', 'true'
+        set 'columns', 'id,score'
+
+        file 'basic_with_duplicate.csv'
+        time 10000 // limit inflight 10s
+    }
+
+    sql "sync"
+
+    qt_partial_update_in_one_stream_load """
+        select * from ${tableName} order by id;
+    """
+
+    streamLoad {
+        table "${tableName}"
+
+        set 'column_separator', ','
+        set 'format', 'csv'
+        set 'partial_columns', 'true'
+        set 'columns', 'id,score'
+
+        file 'basic_with_duplicate2.csv'
+        time 10000 // limit inflight 10s
+    }
+
+    sql "sync"
+
+    qt_partial_update_in_one_stream_load """
+        select * from ${tableName} order by id;
+    """
+
     // drop drop
     sql """ DROP TABLE IF EXISTS ${tableName} """
 }


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

Reply via email to