From c02c00974f6df26fde8729811d8833a225df01b9 Mon Sep 17 00:00:00 2001 From: Pxl Date: Fri, 10 Nov 2023 11:03:13 +0800 Subject: [PATCH] [Bug](agg-state) fix file load insert wrong data to agg_state (#26581) fix file load insert wrong data to agg_state --- .../org/apache/doris/planner/ScanNode.java | 3 +- .../data/mv_p0/dis_26495/dis_26495.out | 9 ++++ regression-test/data/mv_p0/dis_26495/test.csv | 3 ++ .../suites/mv_p0/dis_26495/dis_26495.groovy | 42 +++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 regression-test/data/mv_p0/dis_26495/dis_26495.out create mode 100644 regression-test/data/mv_p0/dis_26495/test.csv create mode 100644 regression-test/suites/mv_p0/dis_26495/dis_26495.groovy diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/ScanNode.java b/fe/fe-core/src/main/java/org/apache/doris/planner/ScanNode.java index 6a409975eaafe5..b42a70f125fbee 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/ScanNode.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/ScanNode.java @@ -130,7 +130,8 @@ protected Expr castToSlot(SlotDescriptor slotDesc, Expr expr) throws UserExcepti if (PrimitiveType.typeWithPrecision.contains(dstType) && PrimitiveType.typeWithPrecision.contains(srcType) && !slotDesc.getType().equals(expr.getType())) { return expr.castTo(slotDesc.getType()); - } else if (dstType != srcType) { + } else if (dstType != srcType || slotDesc.getType().isAggStateType() && expr.getType().isAggStateType() + && !slotDesc.getType().equals(expr.getType())) { return expr.castTo(slotDesc.getType()); } else { return expr; diff --git a/regression-test/data/mv_p0/dis_26495/dis_26495.out b/regression-test/data/mv_p0/dis_26495/dis_26495.out new file mode 100644 index 00000000000000..51bc5cf2e0b53f --- /dev/null +++ b/regression-test/data/mv_p0/dis_26495/dis_26495.out @@ -0,0 +1,9 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +1 + +-- !select -- +1 2 1 +1 3 1 +2 2 2 + diff --git a/regression-test/data/mv_p0/dis_26495/test.csv b/regression-test/data/mv_p0/dis_26495/test.csv new file mode 100644 index 00000000000000..0f6ba30ad8a2d1 --- /dev/null +++ b/regression-test/data/mv_p0/dis_26495/test.csv @@ -0,0 +1,3 @@ +1,2 +2,2 +1,3 diff --git a/regression-test/suites/mv_p0/dis_26495/dis_26495.groovy b/regression-test/suites/mv_p0/dis_26495/dis_26495.groovy new file mode 100644 index 00000000000000..4cc3842b9914f4 --- /dev/null +++ b/regression-test/suites/mv_p0/dis_26495/dis_26495.groovy @@ -0,0 +1,42 @@ +// 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 ("dis_26495") { + sql "set enable_agg_state=true" + sql """ DROP TABLE IF EXISTS doris_test; """ + + sql """ + create table doris_test (a int,b int, agg_st_1 agg_state max_by(int ,int)) + DISTRIBUTED BY HASH(a) BUCKETS 1 properties("replication_num" = "1"); + """ + + sql """insert into doris_test values (1,2,max_by_state(1,2));""" + + streamLoad { + table "doris_test" + set 'column_separator', ',' + set 'columns', 'a, b, agg_st_1=max_by_state(a,b)' + + file './test.csv' + time 10000 // limit inflight 10s + } + + qt_select """select max_by_merge(agg_st_1) from doris_test""" + qt_select """select a,b,max_by_merge(agg_st_1) from doris_test group by a,b order by a,b""" +}