diff --git a/dbms/src/Flash/tests/gtest_projection_executor.cpp b/dbms/src/Flash/tests/gtest_projection_executor.cpp index d7e90b6cb51..599044f5503 100644 --- a/dbms/src/Flash/tests/gtest_projection_executor.cpp +++ b/dbms/src/Flash/tests/gtest_projection_executor.cpp @@ -343,7 +343,7 @@ try .scan("test_db", "test_table3") .project({lit(Field(String("a")))}) .build(context); - executeAndAssertColumnsEqual(req, {createColumns({toVec({"a", "a", "a", "a", "a"})})}); + executeAndAssertColumnsEqual(req, {createColumns({createConstColumn(5, "a")})}); req = context .scan("test_db", "test_table3") @@ -351,7 +351,7 @@ try .project(MockAstVec{}) .project({lit(Field(String("a")))}) .build(context); - executeAndAssertColumnsEqual(req, {createColumns({toVec({"a", "a", "a", "a", "a"})})}); + executeAndAssertColumnsEqual(req, {createColumns({createConstColumn(5, "a")})}); req = context .scan("test_db", "test_table3") @@ -359,7 +359,7 @@ try .project(MockAstVec{}) .project({lit(Field(String("a")))}) .build(context); - executeAndAssertColumnsEqual(req, {createColumns({toVec({"a", "a", "a", "a", "a"})})}); + executeAndAssertColumnsEqual(req, {createColumns({createConstColumn(5, "a")})}); req = context .scan("test_db", "test_table3") diff --git a/dbms/src/Storages/DeltaMerge/tests/gtest_segment_test_basic.cpp b/dbms/src/Storages/DeltaMerge/tests/gtest_segment_test_basic.cpp index a890c868d0b..85c54c5e7c0 100644 --- a/dbms/src/Storages/DeltaMerge/tests/gtest_segment_test_basic.cpp +++ b/dbms/src/Storages/DeltaMerge/tests/gtest_segment_test_basic.cpp @@ -303,22 +303,7 @@ Block SegmentTestBasic::prepareWriteBlock(Int64 start_key, Int64 end_key, bool i Block sortMergeBlocks(std::vector && blocks) { - auto accumulated_block = std::move(blocks[0]); - - for (size_t block_idx = 1; block_idx < blocks.size(); ++block_idx) - { - auto block = std::move(blocks[block_idx]); - - size_t columns = block.columns(); - size_t rows = block.rows(); - - for (size_t i = 0; i < columns; ++i) - { - MutableColumnPtr mutable_column = (*std::move(accumulated_block.getByPosition(i).column)).mutate(); - mutable_column->insertRangeFrom(*block.getByPosition(i).column, 0, rows); - accumulated_block.getByPosition(i).column = std::move(mutable_column); - } - } + auto accumulated_block = mergeBlocks(std::move(blocks)); SortDescription sort; sort.emplace_back(EXTRA_HANDLE_COLUMN_NAME, 1, 0); diff --git a/dbms/src/TestUtils/ExecutorTestUtils.cpp b/dbms/src/TestUtils/ExecutorTestUtils.cpp index 7719d021b37..7ca140ee650 100644 --- a/dbms/src/TestUtils/ExecutorTestUtils.cpp +++ b/dbms/src/TestUtils/ExecutorTestUtils.cpp @@ -166,34 +166,6 @@ void ExecutorTest::executeAndAssertRowsEqual(const std::shared_ptr actual_cols; - for (const auto & column : sample_block.getColumnsWithTypeAndName()) - { - actual_cols.push_back(column.type->createColumn()); - } - for (const auto & block : blocks) - { - for (size_t i = 0; i < block.columns(); ++i) - { - for (size_t j = 0; j < block.rows(); ++j) - { - actual_cols[i]->insert((*(block.getColumnsWithTypeAndName())[i].column)[j]); - } - } - } - - ColumnsWithTypeAndName actual_columns; - for (size_t i = 0; i < actual_cols.size(); ++i) - actual_columns.push_back({std::move(actual_cols[i]), sample_block.getColumnsWithTypeAndName()[i].type, sample_block.getColumnsWithTypeAndName()[i].name, sample_block.getColumnsWithTypeAndName()[i].column_id}); - return Block(actual_columns); -} - void readStream(Blocks & blocks, BlockInputStreamPtr stream) { stream->readPrefix(); @@ -214,7 +186,7 @@ DB::ColumnsWithTypeAndName readBlocks(std::vector streams) Blocks actual_blocks; for (const auto & stream : streams) readStream(actual_blocks, stream); - return mergeBlocksForTest(std::move(actual_blocks)).getColumnsWithTypeAndName(); + return mergeBlocks(std::move(actual_blocks)).getColumnsWithTypeAndName(); } void ExecutorTest::enablePlanner(bool is_enable) @@ -238,7 +210,7 @@ ColumnsWithTypeAndName ExecutorTest::executeStreams(DAGContext * dag_context) // Currently, don't care about regions information in tests. Blocks blocks; queryExecute(context.context, /*internal=*/true)->execute([&blocks](const Block & block) { blocks.push_back(block); }).verify(); - return mergeBlocksForTest(std::move(blocks)).getColumnsWithTypeAndName(); + return mergeBlocks(std::move(blocks)).getColumnsWithTypeAndName(); } Blocks ExecutorTest::getExecuteStreamsReturnBlocks(const std::shared_ptr & request, size_t concurrency)