ClickHouse/tests/queries/0_stateless/01018_ddl_dictionaries_create.sql

165 lines
4.2 KiB
MySQL
Raw Normal View History

2020-06-20 11:29:01 +00:00
SET send_logs_level = 'fatal';
2019-10-11 15:22:30 +00:00
2019-10-15 18:04:17 +00:00
DROP DATABASE IF EXISTS database_for_dict;
CREATE DATABASE database_for_dict Engine = Ordinary;
DROP TABLE IF EXISTS database_for_dict.table_for_dict;
CREATE TABLE database_for_dict.table_for_dict
(
key_column UInt64,
second_column UInt8,
third_column String
)
ENGINE = MergeTree()
ORDER BY key_column;
INSERT INTO database_for_dict.table_for_dict VALUES (1, 100, 'Hello world');
2019-10-11 15:22:30 +00:00
DROP DATABASE IF EXISTS ordinary_db;
CREATE DATABASE ordinary_db ENGINE = Ordinary;
SELECT '=DICTIONARY in Ordinary DB';
DROP DICTIONARY IF EXISTS ordinary_db.dict1;
CREATE DICTIONARY ordinary_db.dict1
(
2019-10-16 17:06:52 +00:00
key_column UInt64 DEFAULT 0,
second_column UInt8 DEFAULT 1,
third_column String DEFAULT 'qqq'
2019-10-11 15:22:30 +00:00
)
PRIMARY KEY key_column
2019-10-15 18:04:17 +00:00
SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'table_for_dict' PASSWORD '' DB 'database_for_dict'))
2019-10-11 15:22:30 +00:00
LIFETIME(MIN 1 MAX 10)
LAYOUT(FLAT());
SHOW CREATE DICTIONARY ordinary_db.dict1;
SHOW DICTIONARIES FROM ordinary_db LIKE 'dict1';
EXISTS DICTIONARY ordinary_db.dict1;
SELECT database, name FROM system.dictionaries WHERE name LIKE 'dict1';
SELECT '==DETACH DICTIONARY';
DETACH DICTIONARY ordinary_db.dict1;
SHOW DICTIONARIES FROM ordinary_db LIKE 'dict1';
EXISTS DICTIONARY ordinary_db.dict1;
SELECT database, name FROM system.dictionaries WHERE name LIKE 'dict1';
SELECT '==ATTACH DICTIONARY';
ATTACH DICTIONARY ordinary_db.dict1;
SHOW DICTIONARIES FROM ordinary_db LIKE 'dict1';
EXISTS DICTIONARY ordinary_db.dict1;
SELECT database, name FROM system.dictionaries WHERE name LIKE 'dict1';
SELECT '==DROP DICTIONARY';
DROP DICTIONARY IF EXISTS ordinary_db.dict1;
SHOW DICTIONARIES FROM ordinary_db LIKE 'dict1';
EXISTS DICTIONARY ordinary_db.dict1;
SELECT database, name FROM system.dictionaries WHERE name LIKE 'dict1';
DROP DATABASE IF EXISTS ordinary_db;
DROP DATABASE IF EXISTS memory_db;
CREATE DATABASE memory_db ENGINE = Memory;
SELECT '=DICTIONARY in Memory DB';
CREATE DICTIONARY memory_db.dict2
(
2019-10-15 18:04:17 +00:00
key_column UInt64 DEFAULT 0 INJECTIVE,
2019-10-11 15:22:30 +00:00
second_column UInt8 DEFAULT 1 EXPRESSION rand() % 222,
third_column String DEFAULT 'qqq'
)
PRIMARY KEY key_column
2019-10-15 18:04:17 +00:00
SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'table_for_dict' PASSWORD '' DB 'database_for_dict'))
2019-10-11 15:22:30 +00:00
LIFETIME(MIN 1 MAX 10)
LAYOUT(FLAT()); -- {serverError 48}
2019-10-11 15:22:30 +00:00
2019-10-24 09:33:40 +00:00
SHOW CREATE DICTIONARY memory_db.dict2; -- {serverError 487}
2019-10-11 15:22:30 +00:00
SHOW DICTIONARIES FROM memory_db LIKE 'dict2';
EXISTS DICTIONARY memory_db.dict2;
SELECT database, name FROM system.dictionaries WHERE name LIKE 'dict2';
SELECT '=DICTIONARY in Lazy DB';
DROP DATABASE IF EXISTS lazy_db;
CREATE DATABASE lazy_db ENGINE = Lazy(1);
CREATE DICTIONARY lazy_db.dict3
(
2019-10-15 18:04:17 +00:00
key_column UInt64 DEFAULT 0 INJECTIVE,
second_column UInt8 DEFAULT 1 EXPRESSION rand() % 222,
third_column String DEFAULT 'qqq'
)
PRIMARY KEY key_column, second_column
2019-10-15 18:04:17 +00:00
SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'table_for_dict' PASSWORD '' DB 'database_for_dict'))
LIFETIME(MIN 1 MAX 10)
LAYOUT(COMPLEX_KEY_HASHED()); -- {serverError 48}
DROP DATABASE IF EXISTS lazy_db;
2019-10-14 09:52:43 +00:00
SELECT '=DROP DATABASE WITH DICTIONARY';
DROP DATABASE IF EXISTS ordinary_db;
CREATE DATABASE ordinary_db ENGINE = Ordinary;
CREATE DICTIONARY ordinary_db.dict4
(
key_column UInt64 DEFAULT 0,
second_column UInt8 DEFAULT 1,
third_column String DEFAULT 'qqq'
)
PRIMARY KEY key_column
2019-10-15 18:04:17 +00:00
SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'table_for_dict' PASSWORD '' DB 'database_for_dict'))
2019-10-14 09:52:43 +00:00
LIFETIME(MIN 1 MAX 10)
LAYOUT(FLAT());
SHOW DICTIONARIES FROM ordinary_db;
DROP DATABASE IF EXISTS ordinary_db;
CREATE DATABASE ordinary_db ENGINE = Ordinary;
SHOW DICTIONARIES FROM ordinary_db;
CREATE DICTIONARY ordinary_db.dict4
(
key_column UInt64 DEFAULT 0,
second_column UInt8 DEFAULT 1,
third_column String DEFAULT 'qqq'
)
PRIMARY KEY key_column
2019-10-15 18:04:17 +00:00
SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'table_for_dict' PASSWORD '' DB 'database_for_dict'))
2019-10-14 09:52:43 +00:00
LIFETIME(MIN 1 MAX 10)
LAYOUT(FLAT());
SHOW DICTIONARIES FROM ordinary_db;
DROP DATABASE IF EXISTS ordinary_db;
2019-10-15 18:04:17 +00:00
DROP TABLE IF EXISTS database_for_dict.table_for_dict;
DROP DATABASE IF EXISTS database_for_dict;
DROP DATABASE IF EXISTS memory_db;