Do not convert columns by position when pushing to materialized views (#6415)

* Do not convert columns by position
* Update 00984_materialized_view_to_columns.reference
This commit is contained in:
Ivan 2019-08-11 00:00:13 +03:00 committed by GitHub
parent 838c5e535f
commit cce3ab08bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -193,7 +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 = std::make_shared<ConvertingBlockInputStream>(context, in, view.out->getHeader(), ConvertingBlockInputStream::MatchColumnsMode::Name);
in->readPrefix();

View File

@ -0,0 +1,15 @@
DROP TABLE IF EXISTS test1;
DROP TABLE IF EXISTS test2;
DROP TABLE IF EXISTS mv;
CREATE TABLE test1 (a UInt8, b String) ENGINE MergeTree ORDER BY a;
CREATE TABLE test2 (c UInt8, d String) ENGINE MergeTree ORDER BY c;
CREATE MATERIALIZED VIEW mv TO test1 (b String, a UInt8) AS SELECT d AS b, c AS a FROM test2;
INSERT INTO test2 VALUES (1, 'test');
SELECT * FROM test1;
DROP TABLE test1;
DROP TABLE test2;
DROP TABLE mv;