Fix recursive materialized view

This commit is contained in:
Amos Bird 2019-08-05 01:48:04 +08:00
parent 7388454eb2
commit 39b8141418
3 changed files with 24 additions and 0 deletions

View File

@ -1,4 +1,5 @@
#include <DataStreams/AddingDefaultBlockOutputStream.h>
#include <DataStreams/ConvertingBlockInputStream.h>
#include <DataStreams/PushingToViewsBlockOutputStream.h>
#include <DataStreams/SquashingBlockInputStream.h>
#include <DataTypes/NestedUtils.h>
@ -192,6 +193,7 @@ void PushingToViewsBlockOutputStream::process(const Block & block, size_t view_n
/// and two-level aggregation is triggered).
in = std::make_shared<SquashingBlockInputStream>(
in, context.getSettingsRef().min_insert_block_size_rows, context.getSettingsRef().min_insert_block_size_bytes);
in = std::make_shared<ConvertingBlockInputStream>(context, in, view.out->getHeader(), ConvertingBlockInputStream::MatchColumnsMode::Position);
in->readPrefix();

View File

@ -0,0 +1,4 @@
2
3
3
4

View File

@ -0,0 +1,18 @@
DROP TABLE IF EXISTS test.src;
DROP TABLE IF EXISTS test.dst1;
DROP TABLE IF EXISTS test.dst2;
USE test;
CREATE TABLE src (x UInt8) ENGINE Memory;
CREATE TABLE dst1 (x UInt8) ENGINE Memory;
CREATE MATERIALIZED VIEW src_to_dst1 TO dst1 AS SELECT x + 1 as x FROM src;
CREATE MATERIALIZED VIEW dst2 ENGINE Memory AS SELECT x + 1 as x FROM dst1;
INSERT INTO src VALUES (1), (2);
SELECT * FROM dst1 ORDER BY x;
SELECT * FROM dst2 ORDER BY x;
DROP TABLE src;
DROP TABLE dst1;
DROP TABLE dst2;