Merge pull request #8351 from ClickHouse/fix-dict-with-clickhouse-source-and-subquery

Fix dict with clickhouse source and subquery
This commit is contained in:
Nikolai Kochetov 2019-12-24 16:56:48 +03:00 committed by GitHub
commit 6541b2db9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 0 deletions

View File

@ -76,6 +76,9 @@ ClickHouseDictionarySource::ClickHouseDictionarySource(
context.setUser(user, password, Poco::Net::SocketAddress("127.0.0.1", 0), {});
/// Processors are not supported here yet.
context.getSettingsRef().experimental_use_processors = false;
/// Query context is needed because some code in executeQuery function may assume it exists.
/// Current example is Context::getSampleBlockCache from InterpreterSelectWithUnionQuery::getSampleBlock.
context.makeQueryContext();
}
@ -100,6 +103,7 @@ ClickHouseDictionarySource::ClickHouseDictionarySource(const ClickHouseDictionar
, pool{is_local ? nullptr : createPool(host, port, secure, db, user, password)}
, load_all_query{other.load_all_query}
{
context.makeQueryContext();
}
std::string ClickHouseDictionarySource::getUpdateFieldAndDate()

View File

@ -0,0 +1,16 @@
drop table if exists default.test_01051_d;
drop table if exists default.test_view_01051_d;
drop dictionary if exists default.test_dict_01051_d;
create table default.test_01051_d (key UInt64, value String) engine = MergeTree order by key;
create view default.test_view_01051_d (key UInt64, value String) as select k2 + 1 as key, v2 || '_x' as value from (select key + 2 as k2, value || '_y' as v2 from default.test_01051_d);
insert into default.test_01051_d values (1, 'a');
create dictionary default.test_dict_01051_d (key UInt64, value String) primary key key source(clickhouse(host 'localhost' port '9000' user 'default' password '' db 'default' table 'test_view_01051_d')) layout(flat()) lifetime(100500);
select dictGet('default.test_dict_01051_d', 'value', toUInt64(4));
drop table if exists default.test_01051_d;
drop table if exists default.test_view_01051_d;
drop dictionary if exists default.test_dict_01051_d;