mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Merge pull request #8032 from ClickHouse/ddl_dictionaries_if_not_exists
Create dictionary if not exists
This commit is contained in:
commit
cfa1b37fd6
@ -849,12 +849,12 @@ bool ParserCreateDictionaryQuery::parseImpl(IParser::Pos & pos, ASTPtr & node, E
|
||||
return false;
|
||||
}
|
||||
|
||||
if (s_if_not_exists.ignore(pos, expected))
|
||||
if_not_exists = true;
|
||||
|
||||
if (!s_dictionary.ignore(pos, expected))
|
||||
return false;
|
||||
|
||||
if (s_if_not_exists.ignore(pos, expected))
|
||||
if_not_exists = true;
|
||||
|
||||
if (!name_p.parse(pos, name, expected))
|
||||
return false;
|
||||
|
||||
|
@ -0,0 +1,2 @@
|
||||
1.1
|
||||
1.1
|
@ -0,0 +1,40 @@
|
||||
DROP DATABASE IF EXISTS dictdb;
|
||||
|
||||
CREATE DATABASE dictdb ENGINE = Ordinary;
|
||||
|
||||
CREATE TABLE dictdb.table_for_dict
|
||||
(
|
||||
key_column UInt64,
|
||||
value Float64
|
||||
)
|
||||
ENGINE = MergeTree()
|
||||
ORDER BY key_column;
|
||||
|
||||
INSERT INTO dictdb.table_for_dict VALUES (1, 1.1);
|
||||
|
||||
CREATE DICTIONARY IF NOT EXISTS dictdb.dict_exists
|
||||
(
|
||||
key_column UInt64,
|
||||
value Float64 DEFAULT 77.77
|
||||
)
|
||||
PRIMARY KEY key_column
|
||||
SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'table_for_dict' DB 'dictdb'))
|
||||
LIFETIME(1)
|
||||
LAYOUT(FLAT());
|
||||
|
||||
SELECT dictGetFloat64('dictdb.dict_exists', 'value', toUInt64(1));
|
||||
|
||||
|
||||
CREATE DICTIONARY IF NOT EXISTS dictdb.dict_exists
|
||||
(
|
||||
key_column UInt64,
|
||||
value Float64 DEFAULT 77.77
|
||||
)
|
||||
PRIMARY KEY key_column
|
||||
SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'table_for_dict' DB 'dictdb'))
|
||||
LIFETIME(1)
|
||||
LAYOUT(FLAT());
|
||||
|
||||
SELECT dictGetFloat64('dictdb.dict_exists', 'value', toUInt64(1));
|
||||
|
||||
DROP DATABASE IF EXISTS dictdb;
|
Loading…
Reference in New Issue
Block a user