You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by pa...@apache.org on 2024/03/07 05:08:13 UTC

(doris) branch cp_0307_3 created (now d03abb562c6)

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

panxiaolei pushed a change to branch cp_0307_3
in repository https://gitbox.apache.org/repos/asf/doris.git


      at d03abb562c6 [Bug](load) fix wrong data in mv when routine load with function mapping (#31787)

This branch includes the following new commits:

     new d03abb562c6 [Bug](load) fix wrong data in mv when routine load with function mapping (#31787)

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



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


(doris) 01/01: [Bug](load) fix wrong data in mv when routine load with function mapping (#31787)

Posted by pa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d03abb562c6303471de24a8c53caf9725113ba12
Author: Pxl <px...@qq.com>
AuthorDate: Wed Mar 6 20:39:40 2024 +0800

    [Bug](load) fix wrong data in mv when routine load with function mapping (#31787)
---
 .../src/main/java/org/apache/doris/load/Load.java  |  9 ++--
 .../routine_load_mapping/routine_load_mapping.out  |  9 ++++
 .../data/mv_p0/routine_load_mapping/test           |  1 +
 .../routine_load_mapping.groovy                    | 52 ++++++++++++++++++++++
 4 files changed, 67 insertions(+), 4 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/load/Load.java b/fe/fe-core/src/main/java/org/apache/doris/load/Load.java
index 28969ea8a41..ceecf5466bb 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/load/Load.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/load/Load.java
@@ -855,13 +855,14 @@ public class Load {
             List<SlotRef> slots = Lists.newArrayList();
             entry.getValue().collect(SlotRef.class, slots);
             for (SlotRef slot : slots) {
-                if (slotDescByName.get(slot.getColumnName()) != null) {
-                    smap.getLhs().add(slot);
-                    smap.getRhs().add(getExprFromDesc(analyzer, slotDescByName.get(slot.getColumnName()), slot));
-                } else if (exprsByName.get(slot.getColumnName()) != null) {
+                if (exprsByName.get(slot.getColumnName()) != null) {
                     smap.getLhs().add(slot);
                     smap.getRhs().add(new CastExpr(tbl.getColumn(slot.getColumnName()).getType(),
                             exprsByName.get(slot.getColumnName())));
+                } else if (slotDescByName.get(slot.getColumnName()) != null) {
+                    smap.getLhs().add(slot);
+                    smap.getRhs().add(new CastExpr(tbl.getColumn(slot.getColumnName()).getType(),
+                            new SlotRef(slotDescByName.get(slot.getColumnName()))));
                 } else {
                     if (entry.getKey().equalsIgnoreCase(Column.DELETE_SIGN)) {
                         throw new UserException("unknown reference column in DELETE ON clause:" + slot.getColumnName());
diff --git a/regression-test/data/mv_p0/routine_load_mapping/routine_load_mapping.out b/regression-test/data/mv_p0/routine_load_mapping/routine_load_mapping.out
new file mode 100644
index 00000000000..b70955720b3
--- /dev/null
+++ b/regression-test/data/mv_p0/routine_load_mapping/routine_load_mapping.out
@@ -0,0 +1,9 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !select --
+'ad_sdk_request'	2007-12-01T00:30:19	'b'
+ad_sdk_request	2024-03-04T00:00	a
+
+-- !select_mv --
+2007-12-01T00:30:19	1
+2024-03-04T00:00	1
+
diff --git a/regression-test/data/mv_p0/routine_load_mapping/test b/regression-test/data/mv_p0/routine_load_mapping/test
new file mode 100644
index 00000000000..98b8c2bab05
--- /dev/null
+++ b/regression-test/data/mv_p0/routine_load_mapping/test
@@ -0,0 +1 @@
+'ad_sdk_request',1196440219,'b'
\ No newline at end of file
diff --git a/regression-test/suites/mv_p0/routine_load_mapping/routine_load_mapping.groovy b/regression-test/suites/mv_p0/routine_load_mapping/routine_load_mapping.groovy
new file mode 100644
index 00000000000..1188e3031c0
--- /dev/null
+++ b/regression-test/suites/mv_p0/routine_load_mapping/routine_load_mapping.groovy
@@ -0,0 +1,52 @@
+// 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.
+
+import org.codehaus.groovy.runtime.IOGroovyMethods
+
+suite ("routine_load_mapping") {
+
+    sql """ DROP TABLE IF EXISTS test; """
+
+    sql """
+        CREATE TABLE `test` (
+            `event_id` varchar(50) NULL COMMENT '',
+            `time_stamp` datetime NULL COMMENT '',
+            `device_id` varchar(150) NULL DEFAULT "" COMMENT ''
+            ) ENGINE=OLAP
+            DUPLICATE KEY(`event_id`)
+            DISTRIBUTED BY HASH(`device_id`) BUCKETS AUTO
+            PROPERTIES (
+            "replication_allocation" = "tag.location.default: 1"
+        ); 
+        """
+
+    sql """insert into test(event_id,time_stamp,device_id) values('ad_sdk_request','2024-03-04 00:00:00','a');"""
+
+    createMV("""create materialized view m_view as select time_stamp, count(device_id) from test group by time_stamp;""")
+
+    streamLoad {
+        table "test"
+        set 'column_separator', ','
+        set 'columns', 'event_id,time_stamp,device_id,time_stamp=from_unixtime(`time_stamp`)'
+
+        file './test'
+        time 10000 // limit inflight 10s
+    }
+
+    qt_select "select * from test order by 1,2,3;"
+    qt_select_mv "select * from test index m_view order by 1,2;"
+}


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