fix KafkaStorage build and add sql test for defaults

This commit is contained in:
chertus 2018-07-11 19:24:29 +03:00
parent 82d22574d4
commit a765aef4db
3 changed files with 27 additions and 1 deletions

View File

@ -147,7 +147,7 @@ public:
read_buf = std::make_unique<ReadBufferFromKafkaConsumer>(consumer->stream, storage.log);
reader = FormatFactory::instance().getInput(storage.format_name, *read_buf, storage.getSampleBlock(), context, max_block_size);
const ColumnsDescription & columns = getColumns();
const ColumnsDescription & columns = storage.getColumns();
if (!columns.defaults.empty())
reader = std::make_shared<AddingDefaultsBlockInputStream>(reader, columns.defaults, context);
}

View File

@ -0,0 +1,7 @@
0 0 6 6 6
0 5 5 1.7917595 5
1 1 2 1.0986123 42
1 1 2 1.0986123 42
2 2 4 1.609438 2
3 3 3 3 3
4 0 4 1.609438 42

View File

@ -0,0 +1,19 @@
CREATE DATABASE IF NOT EXISTS test;
DROP TABLE IF EXISTS test.defaults;
CREATE TABLE IF NOT EXISTS test.defaults
(
x UInt32,
y UInt32,
a UInt32 DEFAULT x + y,
b Float32 DEFAULT log(1 + x + y),
c UInt32 DEFAULT 42
) ENGINE = Memory;
INSERT INTO test.defaults FORMAT JSONEachRow {"x":1, "y":1};
INSERT INTO test.defaults (x, y) SELECT x, y FROM test.defaults LIMIT 1;
INSERT INTO test.defaults FORMAT JSONEachRow {"x":2, "y":2, "c":2};
INSERT INTO test.defaults FORMAT JSONEachRow {"x":3, "y":3, "a":3, "b":3, "c":3};
INSERT INTO test.defaults FORMAT JSONEachRow {"x":4} {"y":5, "c":5} {"a":6, "b":6, "c":6};
SELECT * FROM test.defaults ORDER BY (x, y);
DROP TABLE IF EXISTS test.defaults;