Fix header for MergeJoin with constants.

This commit is contained in:
Nikolai Kochetov 2021-01-26 15:37:42 +03:00
parent c2d079d40e
commit 87246ea91b
4 changed files with 24 additions and 2 deletions

View File

@ -501,6 +501,7 @@ void MergeJoin::joinTotals(Block & block) const
void MergeJoin::mergeRightBlocks()
{
std::cerr << "=========== Merging right blocks in_mem " << is_in_memory << std::endl;
if (is_in_memory)
mergeInMemoryRightBlocks();
else
@ -930,7 +931,7 @@ std::shared_ptr<Block> MergeJoin::loadRightBlock(size_t pos) const
{
auto load_func = [&]() -> std::shared_ptr<Block>
{
TemporaryFileStream input(flushed_right_blocks[pos]->path(), right_sample_block);
TemporaryFileStream input(flushed_right_blocks[pos]->path(), materializeBlock(right_sample_block));
return std::make_shared<Block>(input.block_in->read());
};

View File

@ -3,6 +3,7 @@
#include <DataStreams/MergingSortedBlockInputStream.h>
#include <DataStreams/OneBlockInputStream.h>
#include <DataStreams/TemporaryFileStream.h>
#include <DataStreams/materializeBlock.h>
#include <Disks/StoragePolicy.h>
namespace DB
@ -198,7 +199,7 @@ SortedBlocksWriter::SortedFiles SortedBlocksWriter::finishMerge(std::function<vo
BlockInputStreamPtr SortedBlocksWriter::streamFromFile(const TmpFilePtr & file) const
{
return std::make_shared<TemporaryFileLazyInputStream>(file->path(), sample_block);
return std::make_shared<TemporaryFileLazyInputStream>(file->path(), materializeBlock(sample_block));
}
String SortedBlocksWriter::getPath() const

View File

@ -0,0 +1,5 @@
┌─a─┬──────────b─┬─c─┬──────────d─┬─t2.'0.10'─┐
│ a │ 2018-01-01 │ │ 1970-01-01 │ │
│ b │ 2018-01-01 │ B │ 2018-01-01 │ 0.10 │
│ c │ 2018-01-01 │ C │ 2018-01-01 │ 0.10 │
└───┴────────────┴───┴────────────┴───────────┘

View File

@ -0,0 +1,15 @@
DROP TABLE IF EXISTS table1;
DROP TABLE IF EXISTS table2;
CREATE TABLE table1(a String, b Date) ENGINE MergeTree order by a;
CREATE TABLE table2(c String, a String, d Date) ENGINE MergeTree order by c;
INSERT INTO table1 VALUES ('a', '2018-01-01') ('b', '2018-01-01') ('c', '2018-01-01');
INSERT INTO table2 VALUES ('D', 'd', '2018-01-01') ('B', 'b', '2018-01-01') ('C', 'c', '2018-01-01');
set join_algorithm = 'partial_merge';
SELECT * FROM table1 AS t1 ALL LEFT JOIN (SELECT *, '0.10', c, d AS b FROM table2) AS t2 USING (a, b) ORDER BY d ASC FORMAT PrettyCompact settings max_rows_in_join = 1;
DROP TABLE IF EXISTS table1;
DROP TABLE IF EXISTS table2;