You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by zh...@apache.org on 2023/03/09 12:59:32 UTC

[doris] branch master updated: [fix](sequence) fix that the result is wrong when load multiple duplicate keys (#17575)

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

zhangchen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 849b5b7b8f [fix](sequence) fix that the result is wrong when load multiple duplicate keys (#17575)
849b5b7b8f is described below

commit 849b5b7b8fd3df38504cbe918f674c0f357e9007
Author: Xin Liao <li...@126.com>
AuthorDate: Thu Mar 9 20:59:23 2023 +0800

    [fix](sequence) fix that the result is wrong when load multiple duplicate keys (#17575)
---
 be/src/olap/memtable.cpp                           |  3 +
 .../unique/sequence_multi_same_key.csv             |  6 ++
 .../unique/test_sequence_multi_same_key.out        |  4 ++
 .../unique/test_sequence_multi_same_key.groovy     | 65 ++++++++++++++++++++++
 4 files changed, 78 insertions(+)

diff --git a/be/src/olap/memtable.cpp b/be/src/olap/memtable.cpp
index d6137fe842..416107eb81 100644
--- a/be/src/olap/memtable.cpp
+++ b/be/src/olap/memtable.cpp
@@ -226,6 +226,9 @@ void MemTable::_aggregate_two_row_in_block(RowInBlock* new_row, RowInBlock* row_
         if (res > 0) {
             return;
         }
+        // need to update the row pos in skiplist to the new row pos when has
+        // sequence column
+        row_in_skiplist->_row_pos = new_row->_row_pos;
     }
     // dst is non-sequence row, or dst sequence is smaller
     for (uint32_t cid = _schema->num_key_columns(); cid < _schema->num_columns(); ++cid) {
diff --git a/regression-test/data/data_model_p0/unique/sequence_multi_same_key.csv b/regression-test/data/data_model_p0/unique/sequence_multi_same_key.csv
new file mode 100644
index 0000000000..59d0828cb2
--- /dev/null
+++ b/regression-test/data/data_model_p0/unique/sequence_multi_same_key.csv
@@ -0,0 +1,6 @@
+1,2020-02-22,1,2020-02-21,a
+1,2020-02-22,1,2020-02-22,b
+1,2020-02-22,1,2020-03-05,c
+1,2020-02-22,1,2020-02-26,d
+1,2020-02-22,1,2020-02-23,e
+1,2020-02-22,1,2020-02-24,b
diff --git a/regression-test/data/data_model_p0/unique/test_sequence_multi_same_key.out b/regression-test/data/data_model_p0/unique/test_sequence_multi_same_key.out
new file mode 100644
index 0000000000..07c222f01a
--- /dev/null
+++ b/regression-test/data/data_model_p0/unique/test_sequence_multi_same_key.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !all --
+1	2020-02-22	1	2020-03-05	c
+
diff --git a/regression-test/suites/data_model_p0/unique/test_sequence_multi_same_key.groovy b/regression-test/suites/data_model_p0/unique/test_sequence_multi_same_key.groovy
new file mode 100644
index 0000000000..f8058a12d8
--- /dev/null
+++ b/regression-test/suites/data_model_p0/unique/test_sequence_multi_same_key.groovy
@@ -0,0 +1,65 @@
+// 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_sequence_multi_same_key") {
+    def tableName = "sequence_multi_same_key"
+    sql "DROP TABLE IF EXISTS ${tableName}"
+    sql """
+        CREATE TABLE IF NOT EXISTS ${tableName} (
+            `user_id` bigint,
+            `date` date,
+            `group_id` bigint,
+            `modify_date` date,
+            `keyword` VARCHAR(128)
+            ) ENGINE=OLAP
+        UNIQUE KEY(user_id, date, group_id)
+        DISTRIBUTED BY HASH (user_id) BUCKETS 1
+        PROPERTIES(
+                "function_column.sequence_col" = 'modify_date',
+                "replication_num" = "1",
+                "in_memory" = "false"
+                );
+    """
+    // load unique key
+    streamLoad {
+        table "${tableName}"
+
+        set 'column_separator', ','
+
+        file 'sequence_multi_same_key.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("success", json.Status.toLowerCase())
+            assertEquals(6, json.NumberTotalRows)
+            assertEquals(6, json.NumberLoadedRows)
+            assertEquals(0, json.NumberFilteredRows)
+            assertEquals(0, json.NumberUnselectedRows)
+        }
+    }
+    sql "sync"
+
+    order_qt_all "SELECT * from ${tableName}"
+
+    sql "DROP TABLE ${tableName}"
+}
+


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