ClickHouse/dbms/tests/queries/0_stateless/00753_system_columns_and_system_tables.sql

69 lines
1.9 KiB
MySQL
Raw Normal View History

CREATE DATABASE IF NOT EXISTS test;
DROP TABLE IF EXISTS test.check_system_tables;
-- Check MergeTree declaration in new format
CREATE TABLE test.check_system_tables
(
name1 UInt8,
name2 UInt8,
name3 UInt8
) ENGINE = MergeTree()
ORDER BY name1
PARTITION BY name2
SAMPLE BY name1;
2018-11-27 17:07:10 +00:00
SELECT name, partition_key, sorting_key, primary_key, sampling_key
FROM system.tables
WHERE name = 'check_system_tables'
FORMAT PrettyCompactNoEscapes;
2018-11-27 17:07:10 +00:00
SELECT name, is_in_partition_key, is_in_sorting_key, is_in_primary_key, is_in_sampling_key
FROM system.columns
WHERE table = 'check_system_tables'
FORMAT PrettyCompactNoEscapes;
DROP TABLE IF EXISTS test.check_system_tables;
-- Check VersionedCollapsingMergeTree
CREATE TABLE test.check_system_tables
(
date Date,
value String,
version UInt64,
sign Int8
) ENGINE = VersionedCollapsingMergeTree(sign, version)
PARTITION BY date
ORDER BY date;
2018-11-27 17:07:10 +00:00
SELECT name, partition_key, sorting_key, primary_key, sampling_key
FROM system.tables
WHERE name = 'check_system_tables'
FORMAT PrettyCompactNoEscapes;
2018-11-27 17:07:10 +00:00
SELECT name, is_in_partition_key, is_in_sorting_key, is_in_primary_key, is_in_sampling_key
FROM system.columns
WHERE table = 'check_system_tables'
FORMAT PrettyCompactNoEscapes;
DROP TABLE IF EXISTS test.check_system_tables;
-- Check MergeTree declaration in old format
CREATE TABLE test.check_system_tables
(
Event Date,
UserId UInt32,
Counter UInt32
) ENGINE = MergeTree(Event, intHash32(UserId), (Counter, Event, intHash32(UserId)), 8192);
2018-11-27 17:07:10 +00:00
SELECT name, partition_key, sorting_key, primary_key, sampling_key
FROM system.tables
WHERE name = 'check_system_tables'
FORMAT PrettyCompactNoEscapes;
2018-11-27 17:07:10 +00:00
SELECT name, is_in_partition_key, is_in_sorting_key, is_in_primary_key, is_in_sampling_key
FROM system.columns
WHERE table = 'check_system_tables'
FORMAT PrettyCompactNoEscapes;
DROP TABLE IF EXISTS test.check_system_tables;