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

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

commit bcda1d80c2c19e3a988989d26813547d128e2cd2
Author: Pxl <pxl...@qq.com>
AuthorDate: Tue Apr 9 10:53:57 2024 +0800

    [Bug](load) fix stream load file on hll type mv column (#33373)
    
    fix stream load file on hll type mv column
---
 .../src/main/java/org/apache/doris/load/Load.java  |  9 +++-
 .../mv_p0/routine_load_hll/routine_load_hll.out    |  9 ++++
 regression-test/data/mv_p0/routine_load_hll/test   |  1 +
 .../mv_p0/routine_load_hll/routine_load_hll.groovy | 59 ++++++++++++++++++++++
 4 files changed, 76 insertions(+), 2 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 cbd3c21a30c..ed86310b435 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
@@ -570,8 +570,13 @@ public class Load {
             for (SlotRef slot : slots) {
                 if (exprsByName.get(slot.getColumnName()) != null) {
                     smap.getLhs().add(slot);
-                    smap.getRhs().add(new 
CastExpr(tbl.getColumn(slot.getColumnName()).getType(),
-                            exprsByName.get(slot.getColumnName())));
+                    if (tbl.getColumn(slot.getColumnName()).getType()
+                            
.equals(exprsByName.get(slot.getColumnName()).getType())) {
+                        
smap.getRhs().add(exprsByName.get(slot.getColumnName()));
+                    } else {
+                        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(
diff --git a/regression-test/data/mv_p0/routine_load_hll/routine_load_hll.out 
b/regression-test/data/mv_p0/routine_load_hll/routine_load_hll.out
new file mode 100644
index 00000000000..222578deb50
--- /dev/null
+++ b/regression-test/data/mv_p0/routine_load_hll/routine_load_hll.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'       \N      1
+ad_sdk_request 2024-03-04T00:00        2
+
+-- !select_mv --
+\N     1
+2024-03-04T00:00       2
+
diff --git a/regression-test/data/mv_p0/routine_load_hll/test 
b/regression-test/data/mv_p0/routine_load_hll/test
new file mode 100644
index 00000000000..98b8c2bab05
--- /dev/null
+++ b/regression-test/data/mv_p0/routine_load_hll/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_hll/routine_load_hll.groovy 
b/regression-test/suites/mv_p0/routine_load_hll/routine_load_hll.groovy
new file mode 100644
index 00000000000..6438b057723
--- /dev/null
+++ b/regression-test/suites/mv_p0/routine_load_hll/routine_load_hll.groovy
@@ -0,0 +1,59 @@
+// 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_hll") {
+
+    sql """ DROP TABLE IF EXISTS test; """
+
+    sql """
+        CREATE TABLE `test` (
+            `event_id` varchar(50) NULL,
+            `time_stamp` datetime NULL,
+            `device_id` hll hll_union
+            ) ENGINE=OLAP
+            AGGREGATE KEY(`event_id`,`time_stamp`)
+            DISTRIBUTED BY HASH(`event_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',hll_hash('a'));"""
+
+    createMV("""create materialized view m_view as select time_stamp, 
hll_union(device_id) from test group by time_stamp;""")
+
+        sql """insert into test(event_id,time_stamp,device_id) 
values('ad_sdk_request','2024-03-04 00:00:00',hll_hash('b'));"""
+
+    streamLoad {
+        table "test"
+        set 'column_separator', ','
+        set 'columns', 
'event_id,time_stamp,device_id,device_id=hll_hash(device_id)'
+
+        file './test'
+        time 10000 // limit inflight 10s
+    }
+
+    qt_select "select event_id,time_stamp,hll_cardinality(device_id) from test 
order by 1,2;"
+
+    explain {
+        sql("select time_stamp, hll_union_agg(device_id) from test group by 
time_stamp order by 1;")
+        contains "(m_view)"
+    }
+    qt_select_mv "select time_stamp, hll_union_agg(device_id) from test group 
by time_stamp order by 1;"
+}


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

Reply via email to