Skip to content

Commit

Permalink
[Bug](agg-state) fix file load insert wrong data to agg_state (apache…
Browse files Browse the repository at this point in the history
…#26581)

fix file load insert wrong data to agg_state
  • Loading branch information
BiteTheDDDDt authored Nov 10, 2023
1 parent 7ce7466 commit c02c009
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions regression-test/data/mv_p0/dis_26495/dis_26495.out
Original file line number Diff line number Diff line change
@@ -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

3 changes: 3 additions & 0 deletions regression-test/data/mv_p0/dis_26495/test.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1,2
2,2
1,3
42 changes: 42 additions & 0 deletions regression-test/suites/mv_p0/dis_26495/dis_26495.groovy
Original file line number Diff line number Diff line change
@@ -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"""
}

0 comments on commit c02c009

Please sign in to comment.