Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create dictionary if not exists #8032

Merged
merged 1 commit into from
Dec 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions dbms/src/Parsers/ParserCreateQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1.1
1.1
Original file line number Diff line number Diff line change
@@ -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;