ClickHouse/tests/queries/0_stateless/01414_low_cardinality_nullable.sql

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

223 lines
9.5 KiB
MySQL
Raw Normal View History

2020-07-23 16:46:38 +00:00
DROP TABLE IF EXISTS lc_nullable;
CREATE TABLE lc_nullable (
2021-01-28 04:43:59 +00:00
order_key Array(LowCardinality(Nullable(UInt64))),
2020-07-23 16:46:38 +00:00
i8 Array(LowCardinality(Nullable(Int8))),
i16 Array(LowCardinality(Nullable(Int16))),
i32 Array(LowCardinality(Nullable(Int32))),
i64 Array(LowCardinality(Nullable(Int64))),
u8 Array(LowCardinality(Nullable(UInt8))),
u16 Array(LowCardinality(Nullable(UInt16))),
u32 Array(LowCardinality(Nullable(UInt32))),
u64 Array(LowCardinality(Nullable(UInt64))),
f32 Array(LowCardinality(Nullable(Float32))),
f64 Array(LowCardinality(Nullable(Float64))),
2021-01-28 04:43:59 +00:00
date Array(LowCardinality(Nullable(Date))),
2022-03-11 23:45:26 +00:00
date_time Array(LowCardinality(Nullable(DateTime('Asia/Istanbul')))),
2020-07-23 16:46:38 +00:00
2021-01-28 04:43:59 +00:00
str Array(LowCardinality(Nullable(String))),
2020-07-23 16:46:38 +00:00
fixed_string Array(LowCardinality(Nullable(FixedString(5))))
2021-12-28 17:06:21 +00:00
) ENGINE = MergeTree() ORDER BY order_key SETTINGS allow_nullable_key = 1;
2020-07-23 16:46:38 +00:00
INSERT INTO lc_nullable SELECT
groupArray(number) AS order_key,
groupArray(toInt8(number)) AS i8,
groupArray(toInt16(number)) AS i16,
groupArray(toInt32(number)) AS i32,
groupArray(toInt64(number)) AS i64,
groupArray(toUInt8(number)) AS u8,
groupArray(toUInt16(number)) AS u16,
groupArray(toUInt32(number)) AS u32,
groupArray(toUInt64(number)) AS u64,
groupArray(toFloat32(number)) AS f32,
groupArray(toFloat64(number)) AS f64,
2022-03-11 23:45:26 +00:00
groupArray(toDate(number, 'Asia/Istanbul')) AS date,
groupArray(toDateTime(number, 'Asia/Istanbul')) AS date_time,
2020-07-23 16:46:38 +00:00
groupArray(toString(number)) AS str,
groupArray(toFixedString(toString(number), 5)) AS fixed_string
FROM (SELECT number FROM system.numbers LIMIT 15);
INSERT INTO lc_nullable SELECT
2020-07-24 12:07:26 +00:00
groupArray(num) AS order_key,
groupArray(toInt8(num)) AS i8,
groupArray(toInt16(num)) AS i16,
groupArray(toInt32(num)) AS i32,
groupArray(toInt64(num)) AS i64,
groupArray(toUInt8(num)) AS u8,
groupArray(toUInt16(num)) AS u16,
groupArray(toUInt32(num)) AS u32,
groupArray(toUInt64(num)) AS u64,
groupArray(toFloat32(num)) AS f32,
groupArray(toFloat64(num)) AS f64,
2022-03-11 23:45:26 +00:00
groupArray(toDate(num, 'Asia/Istanbul')) AS date,
groupArray(toDateTime(num, 'Asia/Istanbul')) AS date_time,
2020-07-24 12:07:26 +00:00
groupArray(toString(num)) AS str,
groupArray(toFixedString(toString(num), 5)) AS fixed_string
FROM (SELECT negate(number) as num FROM system.numbers LIMIT 15);
2020-07-23 16:46:38 +00:00
INSERT INTO lc_nullable SELECT
groupArray(number) AS order_key,
groupArray(toInt8(number)) AS i8,
groupArray(toInt16(number)) AS i16,
groupArray(toInt32(number)) AS i32,
groupArray(toInt64(number)) AS i64,
groupArray(toUInt8(number)) AS u8,
groupArray(toUInt16(number)) AS u16,
groupArray(toUInt32(number)) AS u32,
groupArray(toUInt64(number)) AS u64,
groupArray(toFloat32(number)) AS f32,
groupArray(toFloat64(number)) AS f64,
2022-03-11 23:45:26 +00:00
groupArray(toDate(number, 'Asia/Istanbul')) AS date,
groupArray(toDateTime(number, 'Asia/Istanbul')) AS date_time,
2020-07-23 16:46:38 +00:00
groupArray(toString(number)) AS str,
groupArray(toFixedString(toString(number), 5)) AS fixed_string
FROM (SELECT number FROM system.numbers WHERE number >= 5 LIMIT 15);
INSERT INTO lc_nullable SELECT
groupArray(number) AS order_key,
groupArray(toInt8(number)) AS i8,
groupArray(toInt16(number)) AS i16,
groupArray(toInt32(number)) AS i32,
groupArray(toInt64(number)) AS i64,
groupArray(toUInt8(number)) AS u8,
groupArray(toUInt16(number)) AS u16,
groupArray(toUInt32(number)) AS u32,
groupArray(toUInt64(number)) AS u64,
groupArray(toFloat32(number)) AS f32,
groupArray(toFloat64(number)) AS f64,
2022-03-11 23:45:26 +00:00
groupArray(toDate(number, 'Asia/Istanbul')) AS date,
groupArray(toDateTime(number, 'Asia/Istanbul')) AS date_time,
2020-07-23 16:46:38 +00:00
groupArray(toString(number)) AS str,
groupArray(toFixedString(toString(number), 5)) AS fixed_string
FROM (SELECT number FROM system.numbers WHERE number >= 10 LIMIT 15);
INSERT INTO lc_nullable SELECT
n AS order_key,
n AS i8,
n AS i16,
n AS i32,
n AS i64,
n AS u8,
n AS u16,
n AS u32,
n AS u64,
n AS f32,
n AS f64,
n AS date,
n AS date_time,
n AS str,
n AS fixed_string
FROM (SELECT [NULL] AS n);
INSERT INTO lc_nullable SELECT
[NULL, n] AS order_key,
[NULL, toInt8(n)] AS i8,
[NULL, toInt16(n)] AS i16,
[NULL, toInt32(n)] AS i32,
[NULL, toInt64(n)] AS i64,
[NULL, toUInt8(n)] AS u8,
[NULL, toUInt16(n)] AS u16,
[NULL, toUInt32(n)] AS u32,
[NULL, toUInt64(n)] AS u64,
[NULL, toFloat32(n)] AS f32,
[NULL, toFloat64(n)] AS f64,
2022-03-11 23:45:26 +00:00
[NULL, toDate(n, 'Asia/Istanbul')] AS date,
[NULL, toDateTime(n, 'Asia/Istanbul')] AS date_time,
2020-07-23 16:46:38 +00:00
[NULL, toString(n)] AS str,
[NULL, toFixedString(toString(n), 5)] AS fixed_string
FROM (SELECT 100 as n);
SELECT count() FROM lc_nullable WHERE has(i8, 1);
SELECT count() FROM lc_nullable WHERE has(i16, 1);
SELECT count() FROM lc_nullable WHERE has(i32, 1);
SELECT count() FROM lc_nullable WHERE has(i64, 1);
SELECT count() FROM lc_nullable WHERE has(u8, 1);
SELECT count() FROM lc_nullable WHERE has(u16, 1);
SELECT count() FROM lc_nullable WHERE has(u32, 1);
SELECT count() FROM lc_nullable WHERE has(u64, 1);
SELECT count() FROM lc_nullable WHERE has(f32, 1);
SELECT count() FROM lc_nullable WHERE has(f64, 1);
SELECT count() FROM lc_nullable WHERE has(date, toDate('1970-01-02'));
2022-05-27 00:20:16 +00:00
SELECT count() FROM lc_nullable WHERE has(date_time, toDateTime('1970-01-01 02:00:01', 'Asia/Istanbul'));
2020-07-23 16:46:38 +00:00
SELECT count() FROM lc_nullable WHERE has(str, '1');
SELECT count() FROM lc_nullable WHERE has(fixed_string, toFixedString('1', 5));
SELECT count() FROM lc_nullable WHERE has(i8, -1);
SELECT count() FROM lc_nullable WHERE has(i16, -1);
SELECT count() FROM lc_nullable WHERE has(i32, -1);
SELECT count() FROM lc_nullable WHERE has(i64, -1);
SELECT count() FROM lc_nullable WHERE has(u8, -1);
SELECT count() FROM lc_nullable WHERE has(u16, -1);
SELECT count() FROM lc_nullable WHERE has(u32, -1);
SELECT count() FROM lc_nullable WHERE has(u64, -1);
SELECT count() FROM lc_nullable WHERE has(f32, -1);
SELECT count() FROM lc_nullable WHERE has(f64, -1);
SELECT count() FROM lc_nullable WHERE has(str, '-1');
SELECT count() FROM lc_nullable WHERE has(fixed_string, toFixedString('-1', 5));
SELECT count() FROM lc_nullable WHERE has(i8, 5);
SELECT count() FROM lc_nullable WHERE has(i16, 5);
SELECT count() FROM lc_nullable WHERE has(i32, 5);
SELECT count() FROM lc_nullable WHERE has(i64, 5);
SELECT count() FROM lc_nullable WHERE has(u8, 5);
SELECT count() FROM lc_nullable WHERE has(u16, 5);
SELECT count() FROM lc_nullable WHERE has(u32, 5);
SELECT count() FROM lc_nullable WHERE has(u64, 5);
SELECT count() FROM lc_nullable WHERE has(f32, 5);
SELECT count() FROM lc_nullable WHERE has(f64, 5);
SELECT count() FROM lc_nullable WHERE has(date, toDate('1970-01-06'));
2022-05-27 00:20:16 +00:00
SELECT count() FROM lc_nullable WHERE has(date_time, toDateTime('1970-01-01 02:00:05', 'Asia/Istanbul'));
2020-07-23 16:46:38 +00:00
SELECT count() FROM lc_nullable WHERE has(str, '5');
SELECT count() FROM lc_nullable WHERE has(fixed_string, toFixedString('5', 5));
SELECT count() FROM lc_nullable WHERE has(i8, 10);
SELECT count() FROM lc_nullable WHERE has(i16, 10);
SELECT count() FROM lc_nullable WHERE has(i32, 10);
SELECT count() FROM lc_nullable WHERE has(i64, 10);
SELECT count() FROM lc_nullable WHERE has(u8, 10);
SELECT count() FROM lc_nullable WHERE has(u16, 10);
SELECT count() FROM lc_nullable WHERE has(u32, 10);
SELECT count() FROM lc_nullable WHERE has(u64, 10);
SELECT count() FROM lc_nullable WHERE has(f32, 10);
SELECT count() FROM lc_nullable WHERE has(f64, 10);
SELECT count() FROM lc_nullable WHERE has(date, toDate('1970-01-11'));
2022-05-27 00:20:16 +00:00
SELECT count() FROM lc_nullable WHERE has(date_time, toDateTime('1970-01-01 02:00:10', 'Asia/Istanbul'));
2020-07-23 16:46:38 +00:00
SELECT count() FROM lc_nullable WHERE has(str, '10');
SELECT count() FROM lc_nullable WHERE has(fixed_string, toFixedString('10', 5));
SELECT count() FROM lc_nullable WHERE has(i8, NULL);
SELECT count() FROM lc_nullable WHERE has(i16, NULL);
SELECT count() FROM lc_nullable WHERE has(i32, NULL);
SELECT count() FROM lc_nullable WHERE has(i64, NULL);
SELECT count() FROM lc_nullable WHERE has(u8, NULL);
SELECT count() FROM lc_nullable WHERE has(u16, NULL);
SELECT count() FROM lc_nullable WHERE has(u32, NULL);
SELECT count() FROM lc_nullable WHERE has(u64, NULL);
SELECT count() FROM lc_nullable WHERE has(f32, NULL);
SELECT count() FROM lc_nullable WHERE has(f64, NULL);
SELECT count() FROM lc_nullable WHERE has(date, NULL);
SELECT count() FROM lc_nullable WHERE has(date_time, NULL);
SELECT count() FROM lc_nullable WHERE has(str, NULL);
SELECT count() FROM lc_nullable WHERE has(fixed_string, NULL);
SELECT count() FROM lc_nullable WHERE has(i8, 100);
SELECT count() FROM lc_nullable WHERE has(i16, 100);
SELECT count() FROM lc_nullable WHERE has(i32, 100);
SELECT count() FROM lc_nullable WHERE has(i64, 100);
SELECT count() FROM lc_nullable WHERE has(u8, 100);
SELECT count() FROM lc_nullable WHERE has(u16, 100);
SELECT count() FROM lc_nullable WHERE has(u32, 100);
SELECT count() FROM lc_nullable WHERE has(u64, 100);
SELECT count() FROM lc_nullable WHERE has(f32, 100);
SELECT count() FROM lc_nullable WHERE has(f64, 100);
SELECT count() FROM lc_nullable WHERE has(date, toDate('1970-04-11'));
2022-05-27 00:20:16 +00:00
SELECT count() FROM lc_nullable WHERE has(date_time, toDateTime('1970-01-01 02:01:40', 'Asia/Istanbul'));
2020-07-23 16:46:38 +00:00
SELECT count() FROM lc_nullable WHERE has(str, '100');
SELECT count() FROM lc_nullable WHERE has(fixed_string, toFixedString('100', 5));
2020-09-09 12:52:44 +00:00
SELECT count() FROM lc_nullable WHERE has(date, toDate(has(u64, 1), '1970-01\002'));
2020-07-23 16:46:38 +00:00
DROP TABLE IF EXISTS lc_nullable;