From 9431202f949f983c5d3dfeee3b93156cc5dedff6 Mon Sep 17 00:00:00 2001 From: zhangstar333 <87313068+zhangstar333@users.noreply.github.com> Date: Thu, 26 Sep 2024 11:04:44 +0800 Subject: [PATCH] [Bug](tablet-shuffle) tablet shuffle sink data should use input block rather than convert_block (#41293) ## Proposed changes the convert_block is empty firstly, after execute exprs will be filled. so convert_block maybe different with block. so when send data we still need use block. --- .../pipeline/exec/exchange_sink_operator.cpp | 2 + .../nereids_p0/insert_into_table/random.out | 6 ++ .../insert_into_table/random.groovy | 76 +++++++++++++++++++ 3 files changed, 84 insertions(+) diff --git a/be/src/pipeline/exec/exchange_sink_operator.cpp b/be/src/pipeline/exec/exchange_sink_operator.cpp index cc809da69d9df1..800f81b839bd1a 100644 --- a/be/src/pipeline/exec/exchange_sink_operator.cpp +++ b/be/src/pipeline/exec/exchange_sink_operator.cpp @@ -559,6 +559,8 @@ Status ExchangeSinkOperatorX::sink(RuntimeState* state, vectorized::Block* block local_state._row_distribution._deal_batched = true; RETURN_IF_ERROR(local_state._send_new_partition_batch()); } + // the convert_block maybe different with block after execute exprs + // when send data we still use block RETURN_IF_ERROR(channel_add_rows_with_idx(state, local_state.channels, num_channels, channel2rows, block, eos)); } else if (_part_type == TPartitionType::TABLE_SINK_HASH_PARTITIONED) { diff --git a/regression-test/data/nereids_p0/insert_into_table/random.out b/regression-test/data/nereids_p0/insert_into_table/random.out index dd5bdc8e1d9bb0..c774e023267bc2 100644 --- a/regression-test/data/nereids_p0/insert_into_table/random.out +++ b/regression-test/data/nereids_p0/insert_into_table/random.out @@ -138,3 +138,9 @@ -- !sql_select -- 1 11 11 +-- !sql_select2 -- +1 + +-- !sql_select3 -- +601022201389484209 2024-04-09T20:58:49 卖卖 {"is_poi_first_order":0} + diff --git a/regression-test/suites/nereids_p0/insert_into_table/random.groovy b/regression-test/suites/nereids_p0/insert_into_table/random.groovy index f820ca89bd2de0..9edd855a9a8e56 100644 --- a/regression-test/suites/nereids_p0/insert_into_table/random.groovy +++ b/regression-test/suites/nereids_p0/insert_into_table/random.groovy @@ -54,4 +54,80 @@ suite('nereids_insert_random') { sql """INSERT INTO tbl_4 SELECT k1, k2, k2 FROM tbl_1;""" sql 'sync' qt_sql_select """ select * from tbl_4; """; + + + sql 'drop table if exists tbl_5' + sql 'drop table if exists tbl_6' + sql 'drop table if exists tbl_7' + + sql """ + CREATE TABLE `tbl_5` ( + `orderId` varchar(96) NOT NULL, + `updated_at` datetime NOT NULL, + `userLabel` varchar(255) NULL, + `userTag` variant NULL + ) ENGINE=OLAP + duplicate KEY(`orderId`, `updated_at`) + DISTRIBUTED BY HASH(`orderId`) BUCKETS 1 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" + ); + """ + sql """ + CREATE TABLE tbl_6 + ( + order_id VARCHAR(96) NOT NULL, + updated_at DATETIMEV2 NOT NULL + ) ENGINE=OLAP + duplicate KEY(`order_id`) + DISTRIBUTED BY HASH(`order_id`) BUCKETS 1 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" + ); + """ + + sql """ INSERT INTO `tbl_6` values('601022201389484209', '2024-04-09 20:58:49');""" + + sql """ + CREATE TABLE tbl_7 + ( + orderId VARCHAR(96) NOT NULL, + userLabel VARIANT NULL + )ENGINE=OLAP + UNIQUE KEY(`orderId`) + DISTRIBUTED BY HASH(orderId) BUCKETS AUTO + PROPERTIES ( + "replication_num" = "1" + ); + """ + sql """INSERT INTO `tbl_7` values('601022201389484209','{\"is_poi_first_order\":0}');""" + + sql 'sync' + qt_sql_select2 """ INSERT INTO + tbl_5 + SELECT + A.order_id as orderId, + A.updated_at, + CASE + WHEN LOCATE('下单1次', CAST(B.userLabel AS STRING)) > 0 + OR LOCATE('买买', CAST(B.userLabel AS STRING)) > 0 then '买买' + when B.userLabel ["is_poi_first_order"] = 1 then '买买' + else '卖卖' + end as userLabel, + B.userLabel AS `userTag` + FROM + ( + select + order_id,updated_at + from + tbl_6 + ) AS A + LEFT JOIN ( + select + orderId,userLabel + from + tbl_7 + ) AS B ON A.order_id = B.orderId; """; + qt_sql_select3 """ select * from tbl_5; """; + }