ClickHouse/tests/queries/0_stateless/00395_nullable.sql

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

502 lines
22 KiB
MySQL
Raw Normal View History

2017-12-19 01:44:05 +00:00
SELECT '----- NULL value -----';
SELECT NULL;
SELECT 1 + NULL;
SELECT abs(NULL);
SELECT NULL + NULL;
2017-12-19 01:44:05 +00:00
SELECT '----- MergeTree engine -----';
2019-06-03 17:36:27 +00:00
DROP TABLE IF EXISTS test1_00395;
2022-06-23 08:37:52 +00:00
set allow_deprecated_syntax_for_merge_tree=1;
2019-06-03 17:36:27 +00:00
CREATE TABLE test1_00395(
col1 UInt64, col2 Nullable(UInt64),
col3 String, col4 Nullable(String),
col5 Array(UInt64), col6 Array(Nullable(UInt64)),
col7 Array(String), col8 Array(Nullable(String)),
d Date) Engine = MergeTree(d, (col1, d), 8192);
2024-08-08 10:30:40 +00:00
INSERT INTO test1_00395 VALUES (1, 1, 'a', 'a', [1], [1], ['a'], ['a'], '2000-01-01'),
(1, NULL, 'a', 'a', [1], [1], ['a'], ['a'], '2000-01-01'),
(1, 1, 'a', NULL, [1], [1], ['a'], ['a'], '2000-01-01'),
(1, 1, 'a', 'a', [1], [NULL], ['a'], ['a'], '2000-01-01'),
(1, 1, 'a', 'a', [1], [1], ['a'], [NULL], '2000-01-01');
2019-06-03 17:36:27 +00:00
SELECT * FROM test1_00395 ORDER BY col1,col2,col3,col4,col5,col6,col7,col8 ASC;
2017-12-19 01:44:05 +00:00
SELECT '----- Memory engine -----';
2019-06-03 17:36:27 +00:00
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(
col1 UInt64, col2 Nullable(UInt64),
col3 String, col4 Nullable(String),
col5 Array(UInt64), col6 Array(Nullable(UInt64)),
col7 Array(String), col8 Array(Nullable(String)),
d Date) Engine = Memory;
2024-08-08 10:30:40 +00:00
INSERT INTO test1_00395 VALUES (1, 1, 'a', 'a', [1], [1], ['a'], ['a'], '2000-01-01'),
(1, NULL, 'a', 'a', [1], [1], ['a'], ['a'], '2000-01-01'),
(1, 1, 'a', NULL, [1], [1], ['a'], ['a'], '2000-01-01'),
(1, 1, 'a', 'a', [1], [NULL], ['a'], ['a'], '2000-01-01'),
(1, 1, 'a', 'a', [1], [1], ['a'], [NULL], '2000-01-01');
2019-06-03 17:36:27 +00:00
SELECT * FROM test1_00395 ORDER BY col1,col2,col3,col4,col5,col6,col7,col8 ASC;
2017-12-19 01:44:05 +00:00
SELECT '----- TinyLog engine -----';
2019-06-03 17:36:27 +00:00
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(
col1 UInt64, col2 Nullable(UInt64),
col3 String, col4 Nullable(String),
col5 Array(UInt64), col6 Array(Nullable(UInt64)),
col7 Array(String), col8 Array(Nullable(String)),
d Date) Engine = TinyLog;
2024-08-08 10:30:40 +00:00
INSERT INTO test1_00395 VALUES (1, 1, 'a', 'a', [1], [1], ['a'], ['a'], '2000-01-01'),
(1, NULL, 'a', 'a', [1], [1], ['a'], ['a'], '2000-01-01'),
(1, 1, 'a', NULL, [1], [1], ['a'], ['a'], '2000-01-01'),
(1, 1, 'a', 'a', [1], [NULL], ['a'], ['a'], '2000-01-01'),
(1, 1, 'a', 'a', [1], [1], ['a'], [NULL], '2000-01-01');
2019-06-03 17:36:27 +00:00
SELECT * FROM test1_00395 ORDER BY col1,col2,col3,col4,col5,col6,col7,col8 ASC;
2017-12-19 01:44:05 +00:00
SELECT '----- Log engine -----';
2019-06-03 17:36:27 +00:00
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(
col1 UInt64, col2 Nullable(UInt64),
col3 String, col4 Nullable(String),
col5 Array(UInt64), col6 Array(Nullable(UInt64)),
col7 Array(String), col8 Array(Nullable(String)),
d Date) Engine = Log;
2024-08-08 10:30:40 +00:00
INSERT INTO test1_00395 VALUES (1, 1, 'a', 'a', [1], [1], ['a'], ['a'], '2000-01-01'),
(1, NULL, 'a', 'a', [1], [1], ['a'], ['a'], '2000-01-01'),
(1, 1, 'a', NULL, [1], [1], ['a'], ['a'], '2000-01-01'),
(1, 1, 'a', 'a', [1], [NULL], ['a'], ['a'], '2000-01-01'),
(1, 1, 'a', 'a', [1], [1], ['a'], [NULL], '2000-01-01');
2019-06-03 17:36:27 +00:00
SELECT * FROM test1_00395 ORDER BY col1,col2,col3,col4,col5,col6,col7,col8 ASC;
2017-12-19 01:44:05 +00:00
SELECT '----- StripeLog engine -----';
2019-06-03 17:36:27 +00:00
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(
col1 UInt64, col2 Nullable(UInt64),
col3 String, col4 Nullable(String),
col5 Array(UInt64), col6 Array(Nullable(UInt64)),
col7 Array(String), col8 Array(Nullable(String)),
d Date) Engine = StripeLog;
2024-08-08 10:30:40 +00:00
INSERT INTO test1_00395 VALUES (1, 1, 'a', 'a', [1], [1], ['a'], ['a'], '2000-01-01'),
(1, NULL, 'a', 'a', [1], [1], ['a'], ['a'], '2000-01-01'),
(1, 1, 'a', NULL, [1], [1], ['a'], ['a'], '2000-01-01'),
(1, 1, 'a', 'a', [1], [NULL], ['a'], ['a'], '2000-01-01'),
(1, 1, 'a', 'a', [1], [1], ['a'], [NULL], '2000-01-01');
2019-06-03 17:36:27 +00:00
SELECT * FROM test1_00395 ORDER BY col1,col2,col3,col4,col5,col6,col7,col8 ASC;
2017-12-19 01:44:05 +00:00
SELECT '----- Insert with expression -----';
2019-06-03 17:36:27 +00:00
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 Array(Nullable(UInt64))) Engine=Memory;
INSERT INTO test1_00395(col1) VALUES ([1+1]);
SELECT col1 FROM test1_00395 ORDER BY col1 ASC;
2017-12-19 01:44:05 +00:00
SELECT '----- Insert. Source and target columns have same types up to nullability. -----';
2019-06-03 17:36:27 +00:00
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 Nullable(UInt64), col2 UInt64) Engine=Memory;
DROP TABLE IF EXISTS test2;
CREATE TABLE test2(col1 UInt64, col2 Nullable(UInt64)) Engine=Memory;
2019-06-03 17:36:27 +00:00
INSERT INTO test1_00395(col1,col2) VALUES (2,7)(6,9)(5,1)(4,3)(8,2);
INSERT INTO test2(col1,col2) SELECT col1,col2 FROM test1_00395;
SELECT col1,col2 FROM test2 ORDER BY col1,col2 ASC;
2017-12-19 01:44:05 +00:00
SELECT '----- Apply functions and aggregate functions on columns that may contain null values -----';
2019-06-03 17:36:27 +00:00
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 Nullable(UInt64), col2 Nullable(UInt64)) Engine=Memory;
INSERT INTO test1_00395(col1,col2) VALUES (2,7)(NULL,6)(9,NULL)(NULL,NULL)(5,1)(42,42);
SELECT col1, col2, col1 + col2, col1 * 7 FROM test1_00395 ORDER BY col1,col2 ASC;
SELECT sum(col1) FROM test1_00395;
SELECT sum(col1 * 7) FROM test1_00395;
2017-12-19 01:44:05 +00:00
SELECT '----- isNull, isNotNull -----';
2019-06-03 17:36:27 +00:00
SELECT col1, col2, isNull(col1), isNotNull(col2) FROM test1_00395 ORDER BY col1,col2 ASC;
2017-12-19 01:44:05 +00:00
SELECT '----- ifNull, nullIf -----';
2019-06-03 17:36:27 +00:00
SELECT col1, col2, ifNull(col1,col2) FROM test1_00395 ORDER BY col1,col2 ASC;
SELECT col1, col2, nullIf(col1,col2) FROM test1_00395 ORDER BY col1,col2 ASC;
SELECT nullIf(1, NULL);
2017-12-19 01:44:05 +00:00
SELECT '----- coalesce -----';
SELECT coalesce(NULL);
SELECT coalesce(NULL, 1);
SELECT coalesce(NULL, NULL, 1);
SELECT coalesce(NULL, 42, NULL, 1);
SELECT coalesce(NULL, NULL, NULL);
2019-06-03 17:36:27 +00:00
SELECT col1, col2, coalesce(col1, col2) FROM test1_00395 ORDER BY col1, col2 ASC;
SELECT col1, col2, coalesce(col1, col2, 99) FROM test1_00395 ORDER BY col1, col2 ASC;
2017-12-19 01:44:05 +00:00
SELECT '----- assumeNotNull -----';
2019-06-03 17:36:27 +00:00
SELECT res FROM (SELECT col1, assumeNotNull(col1) AS res FROM test1_00395) WHERE col1 IS NOT NULL ORDER BY res ASC;
2017-12-19 01:44:05 +00:00
SELECT '----- IS NULL, IS NOT NULL -----';
2019-06-03 17:36:27 +00:00
SELECT col1 FROM test1_00395 WHERE col1 IS NOT NULL ORDER BY col1 ASC;
SELECT col1 FROM test1_00395 WHERE col1 IS NULL;
2019-05-10 10:42:00 +00:00
SELECT '----- if -----';
2019-06-07 16:02:24 +00:00
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395 (col1 Nullable(String)) ENGINE=TinyLog;
INSERT INTO test1_00395 VALUES ('a'), ('b'), ('c'), (NULL);
2019-05-10 10:42:00 +00:00
2019-06-07 16:02:24 +00:00
SELECT col1, if(col1 IN ('a' ,'b'), 1, 0) AS t, toTypeName(t) FROM test1_00395;
SELECT col1, if(col1 IN ('a' ,'b'), NULL, 0) AS t, toTypeName(t) FROM test1_00395;
2019-05-10 10:42:00 +00:00
SELECT '----- case when -----';
2019-06-07 16:02:24 +00:00
SELECT col1, CASE WHEN col1 IN ('a' ,'b') THEN 1 ELSE 0 END AS t, toTypeName(t) FROM test1_00395;
SELECT col1, CASE WHEN col1 IN ('a' ,'b') THEN NULL ELSE 0 END AS t, toTypeName(t) FROM test1_00395;
SELECT col1, CASE WHEN col1 IN ('a' ,'b') THEN 1 END AS t, toTypeName(t) FROM test1_00395;
2019-05-10 10:42:00 +00:00
2017-12-19 01:44:05 +00:00
SELECT '----- multiIf -----';
SELECT multiIf(1, NULL, 1, 3, 4);
SELECT multiIf(1, 2, 1, NULL, 4);
SELECT multiIf(NULL, NULL, NULL);
SELECT multiIf(1, 'A', 1, NULL, 'DEF');
SELECT multiIf(1, toFixedString('A', 16), 1, NULL, toFixedString('DEF', 16));
SELECT multiIf(NULL, 2, 1, 3, 4);
SELECT multiIf(1, 2, NULL, 3, 4);
2019-06-03 17:36:27 +00:00
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 Nullable(Int8), col2 Nullable(UInt16), col3 Nullable(Float32)) Engine=TinyLog;
INSERT INTO test1_00395(col1,col2,col3) VALUES (toInt8(1),toUInt16(2),toFloat32(3))(NULL,toUInt16(1),toFloat32(2))(toInt8(1),NULL,toFloat32(2))(toInt8(1),toUInt16(2),NULL);
SELECT multiIf(col1 == 1, col2, col2 == 2, col3, col3 == 3, col1, 42) FROM test1_00395;
2019-06-03 17:36:27 +00:00
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(cond1 Nullable(UInt8), then1 Int8, cond2 UInt8, then2 Nullable(UInt16), then3 Nullable(Float32)) Engine=TinyLog;
INSERT INTO test1_00395(cond1,then1,cond2,then2,then3) VALUES(1,1,1,42,99)(0,7,1,99,42)(NULL,6,2,99,NULL);
SELECT multiIf(cond1,then1,cond2,then2,then3) FROM test1_00395;
2017-12-19 01:44:05 +00:00
SELECT '----- Array functions -----';
SELECT [NULL];
SELECT [NULL,NULL,NULL];
SELECT [NULL,2,3];
SELECT [1,NULL,3];
SELECT [1,2,NULL];
SELECT [NULL,'b','c'];
SELECT ['a',NULL,'c'];
SELECT ['a','b',NULL];
2017-12-19 01:44:05 +00:00
SELECT '----- arrayElement -----';
2017-12-19 01:44:05 +00:00
SELECT '----- constant arrays -----';
SELECT arrayElement([1,NULL,2,3], 1);
SELECT arrayElement([1,NULL,2,3], 2);
SELECT arrayElement([1,NULL,2,3], 3);
SELECT arrayElement([1,NULL,2,3], 4);
SELECT arrayElement(['a',NULL,'c','d'], 1);
SELECT arrayElement(['a',NULL,'c','d'], 2);
SELECT arrayElement(['a',NULL,'c','d'], 3);
SELECT arrayElement(['a',NULL,'c','d'], 4);
2019-06-03 17:36:27 +00:00
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 UInt64) Engine=TinyLog;
INSERT INTO test1_00395(col1) VALUES(1),(2),(3),(4);
2019-06-03 17:36:27 +00:00
SELECT arrayElement([1,NULL,2,3], col1) FROM test1_00395;
2017-12-19 01:44:05 +00:00
SELECT '----- variable arrays -----';
2019-06-03 17:36:27 +00:00
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 Array(Nullable(UInt64))) Engine=TinyLog;
2024-08-08 10:30:40 +00:00
INSERT INTO test1_00395(col1) VALUES([2,3,7,NULL]),
([NULL,3,7,4]),
([2,NULL,7,NULL]),
([2,3,NULL,4]),
([NULL,NULL,NULL,NULL]);
2019-06-03 17:36:27 +00:00
SELECT arrayElement(col1, 1) FROM test1_00395;
SELECT arrayElement(col1, 2) FROM test1_00395;
SELECT arrayElement(col1, 3) FROM test1_00395;
SELECT arrayElement(col1, 4) FROM test1_00395;
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 Array(Nullable(String))) Engine=TinyLog;
2024-08-08 10:30:40 +00:00
INSERT INTO test1_00395(col1) VALUES(['a','bc','def',NULL]),
([NULL,'bc','def','ghij']),
(['a',NULL,'def',NULL]),
(['a','bc',NULL,'ghij']),
([NULL,NULL,NULL,NULL]);
2019-06-03 17:36:27 +00:00
SELECT arrayElement(col1, 1) FROM test1_00395;
SELECT arrayElement(col1, 2) FROM test1_00395;
SELECT arrayElement(col1, 3) FROM test1_00395;
SELECT arrayElement(col1, 4) FROM test1_00395;
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 Array(Nullable(UInt64)), col2 UInt64) Engine=TinyLog;
2024-08-08 10:30:40 +00:00
INSERT INTO test1_00395(col1,col2) VALUES([2,3,7,NULL], 1),
([NULL,3,7,4], 2),
([2,NULL,7,NULL], 3),
([2,3,NULL,4],4),
([NULL,NULL,NULL,NULL],3);
2019-06-03 17:36:27 +00:00
SELECT arrayElement(col1,col2) FROM test1_00395;
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 Array(Nullable(String)), col2 UInt64) Engine=TinyLog;
2024-08-08 10:30:40 +00:00
INSERT INTO test1_00395(col1,col2) VALUES(['a','bc','def',NULL], 1),
([NULL,'bc','def','ghij'], 2),
(['a',NULL,'def','ghij'], 3),
(['a','bc',NULL,'ghij'],4),
([NULL,NULL,NULL,NULL],3);
2019-06-03 17:36:27 +00:00
SELECT arrayElement(col1,col2) FROM test1_00395;
2017-12-19 01:44:05 +00:00
SELECT '----- has -----';
2017-12-19 01:44:05 +00:00
SELECT '----- constant arrays -----';
SELECT has([1,NULL,2,3], 1);
SELECT has([1,NULL,2,3], NULL);
SELECT has([1,NULL,2,3], 2);
SELECT has([1,NULL,2,3], 3);
SELECT has([1,NULL,2,3], 4);
SELECT has(['a',NULL,'def','ghij'], 'a');
SELECT has(['a',NULL,'def','ghij'], NULL);
SELECT has(['a',NULL,'def','ghij'], 'def');
SELECT has(['a',NULL,'def','ghij'], 'ghij');
2019-06-03 17:36:27 +00:00
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 UInt64) Engine=TinyLog;
INSERT INTO test1_00395(col1) VALUES(1),(2),(3),(4);
2019-06-03 17:36:27 +00:00
SELECT has([1,NULL,2,3], col1) FROM test1_00395;
2019-06-03 17:36:27 +00:00
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 Nullable(UInt64)) Engine=TinyLog;
INSERT INTO test1_00395(col1) VALUES(1),(2),(3),(4),(NULL);
2019-06-03 17:36:27 +00:00
SELECT has([1,NULL,2,3], col1) FROM test1_00395;
2019-06-03 17:36:27 +00:00
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 String) Engine=TinyLog;
INSERT INTO test1_00395(col1) VALUES('a'),('bc'),('def'),('ghij');
2019-06-03 17:36:27 +00:00
SELECT has(['a',NULL,'def','ghij'], col1) FROM test1_00395;
2019-06-03 17:36:27 +00:00
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 Nullable(String)) Engine=TinyLog;
INSERT INTO test1_00395(col1) VALUES('a'),('bc'),('def'),('ghij'),(NULL);
2019-06-03 17:36:27 +00:00
SELECT has(['a',NULL,'def','ghij'], col1) FROM test1_00395;
2017-12-19 01:44:05 +00:00
SELECT '----- variable arrays -----';
2019-06-03 17:36:27 +00:00
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 Array(Nullable(UInt64))) Engine=TinyLog;
2024-08-08 10:30:40 +00:00
INSERT INTO test1_00395(col1) VALUES([2,3,7,NULL]),
([NULL,3,7,4]),
([2,NULL,7,NULL]),
([2,3,NULL,4]),
([NULL,NULL,NULL,NULL]);
2019-06-03 17:36:27 +00:00
SELECT has(col1, 2) FROM test1_00395;
SELECT has(col1, 3) FROM test1_00395;
SELECT has(col1, 4) FROM test1_00395;
SELECT has(col1, 5) FROM test1_00395;
SELECT has(col1, 7) FROM test1_00395;
SELECT has(col1, NULL) FROM test1_00395;
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 Array(Nullable(String))) Engine=TinyLog;
2024-08-08 10:30:40 +00:00
INSERT INTO test1_00395(col1) VALUES(['a','bc','def',NULL]),
([NULL,'bc','def','ghij']),
(['a',NULL,'def',NULL]),
(['a','bc',NULL,'ghij']),
([NULL,NULL,NULL,NULL]);
2019-06-03 17:36:27 +00:00
SELECT has(col1, 'a') FROM test1_00395;
SELECT has(col1, 'bc') FROM test1_00395;
SELECT has(col1, 'def') FROM test1_00395;
SELECT has(col1, 'ghij') FROM test1_00395;
SELECT has(col1, NULL) FROM test1_00395;
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 Array(Nullable(UInt64)), col2 UInt64) Engine=TinyLog;
2024-08-08 10:30:40 +00:00
INSERT INTO test1_00395(col1,col2) VALUES([2,3,7,NULL], 2),
([NULL,3,7,4], 3),
([2,NULL,7,NULL], 7),
([2,3,NULL,4],5);
2019-06-03 17:36:27 +00:00
SELECT has(col1,col2) FROM test1_00395;
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 Array(Nullable(UInt64)), col2 Nullable(UInt64)) Engine=TinyLog;
2024-08-08 10:30:40 +00:00
INSERT INTO test1_00395(col1,col2) VALUES([2,3,7,NULL], 2),
([NULL,3,7,4], 3),
([2,NULL,7,NULL], 7),
([2,3,NULL,4],5),
([NULL,NULL,NULL,NULL],NULL);
2019-06-03 17:36:27 +00:00
SELECT has(col1,col2) FROM test1_00395;
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 Array(Nullable(String)), col2 String) Engine=TinyLog;
2024-08-08 10:30:40 +00:00
INSERT INTO test1_00395(col1,col2) VALUES(['a','bc','def',NULL], 'a'),
([NULL,'bc','def','ghij'], 'bc'),
(['a',NULL,'def','ghij'], 'def'),
(['a','bc',NULL,'ghij'], 'ghij');
2019-06-03 17:36:27 +00:00
SELECT has(col1,col2) FROM test1_00395;
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 Array(Nullable(String)), col2 Nullable(String)) Engine=TinyLog;
2024-08-08 10:30:40 +00:00
INSERT INTO test1_00395(col1,col2) VALUES(['a','bc','def',NULL], 'a'),
([NULL,'bc','def','ghij'], 'bc'),
(['a',NULL,'def','ghij'], 'def'),
(['a','bc',NULL,'ghij'], 'ghij'),
([NULL,NULL,NULL,NULL], NULL);
2019-06-03 17:36:27 +00:00
SELECT has(col1,col2) FROM test1_00395;
2017-12-19 01:44:05 +00:00
SELECT '----- Aggregation -----';
2019-06-03 17:36:27 +00:00
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 Nullable(String), col2 Nullable(UInt8), col3 String) ENGINE=TinyLog;
2024-08-08 10:30:40 +00:00
INSERT INTO test1_00395(col1,col2,col3) VALUES('A', 0, 'ABCDEFGH'),
('A', 0, 'BACDEFGH'),
('A', 1, 'BCADEFGH'),
('A', 1, 'BCDAEFGH'),
('B', 1, 'BCDEAFGH'),
('B', 1, 'BCDEFAGH'),
('B', 1, 'BCDEFGAH'),
('B', 1, 'BCDEFGHA'),
('C', 1, 'ACBDEFGH'),
('C', NULL, 'ACDBEFGH'),
('C', NULL, 'ACDEBFGH'),
('C', NULL, 'ACDEFBGH'),
(NULL, 1, 'ACDEFGBH'),
(NULL, NULL, 'ACDEFGHB');
2019-06-03 17:36:27 +00:00
SELECT col1, col2, count() FROM test1_00395 GROUP BY col1, col2 ORDER BY col1, col2;
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 String, col2 Nullable(UInt8), col3 String) ENGINE=TinyLog;
2024-08-08 10:30:40 +00:00
INSERT INTO test1_00395(col1,col2,col3) VALUES('A', 0, 'ABCDEFGH'),
('A', 0, 'BACDEFGH'),
('A', 1, 'BCADEFGH'),
('A', 1, 'BCDAEFGH'),
('B', 1, 'BCDEAFGH'),
('B', 1, 'BCDEFAGH'),
('B', 1, 'BCDEFGAH'),
('B', 1, 'BCDEFGHA'),
('C', 1, 'ACBDEFGH'),
('C', NULL, 'ACDBEFGH'),
('C', NULL, 'ACDEBFGH'),
('C', NULL, 'ACDEFBGH');
2019-06-03 17:36:27 +00:00
SELECT col1, col2, count() FROM test1_00395 GROUP BY col1, col2 ORDER BY col1, col2;
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 Nullable(String), col2 String) ENGINE=TinyLog;
2024-08-08 10:30:40 +00:00
INSERT INTO test1_00395(col1,col2) VALUES('A', 'ABCDEFGH'),
('A', 'BACDEFGH'),
('A', 'BCADEFGH'),
('A', 'BCDAEFGH'),
('B', 'BCDEAFGH'),
('B', 'BCDEFAGH'),
('B', 'BCDEFGAH'),
('B', 'BCDEFGHA'),
('C', 'ACBDEFGH'),
('C', 'ACDBEFGH'),
('C', 'ACDEBFGH'),
('C', 'ACDEFBGH'),
(NULL, 'ACDEFGBH'),
(NULL, 'ACDEFGHB');
2019-06-03 17:36:27 +00:00
SELECT col1, count() FROM test1_00395 GROUP BY col1 ORDER BY col1;
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 Nullable(UInt8), col2 String) ENGINE=TinyLog;
2024-08-08 10:30:40 +00:00
INSERT INTO test1_00395(col1,col2) VALUES(0, 'ABCDEFGH'),
(0, 'BACDEFGH'),
(1, 'BCADEFGH'),
(1, 'BCDAEFGH'),
(1, 'BCDEAFGH'),
(1, 'BCDEFAGH'),
(1, 'BCDEFGAH'),
(1, 'BCDEFGHA'),
(1, 'ACBDEFGH'),
(NULL, 'ACDBEFGH'),
(NULL, 'ACDEBFGH'),
(NULL, 'ACDEFBGH');
2019-06-03 17:36:27 +00:00
SELECT col1, count() FROM test1_00395 GROUP BY col1 ORDER BY col1;
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 Nullable(UInt64), col2 UInt64, col3 String) ENGINE=TinyLog;
2024-08-08 10:30:40 +00:00
INSERT INTO test1_00395(col1,col2,col3) VALUES(0, 2, 'ABCDEFGH'),
(0, 3, 'BACDEFGH'),
(1, 5, 'BCADEFGH'),
(1, 2, 'BCDAEFGH'),
(1, 3, 'BCDEAFGH'),
(1, 5, 'BCDEFAGH'),
(1, 2, 'BCDEFGAH'),
(1, 3, 'BCDEFGHA'),
(1, 5, 'ACBDEFGH'),
(NULL, 2, 'ACDBEFGH'),
(NULL, 3, 'ACDEBFGH'),
(NULL, 3, 'ACDEFBGH');
2019-06-03 17:36:27 +00:00
SELECT col1, col2, count() FROM test1_00395 GROUP BY col1, col2 ORDER BY col1, col2;
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 Nullable(UInt64), col2 UInt64, col3 Nullable(UInt64), col4 String) ENGINE=TinyLog;
2024-08-08 10:30:40 +00:00
INSERT INTO test1_00395(col1,col2,col3,col4) VALUES(0, 2, 1, 'ABCDEFGH'),
(0, 3, NULL, 'BACDEFGH'),
(1, 5, 1, 'BCADEFGH'),
(1, 2, NULL, 'BCDAEFGH'),
(1, 3, 1, 'BCDEAFGH'),
(1, 5, NULL, 'BCDEFAGH'),
(1, 2, 1, 'BCDEFGAH'),
(1, 3, NULL, 'BCDEFGHA'),
(1, 5, 1, 'ACBDEFGH'),
(NULL, 2, NULL, 'ACDBEFGH'),
(NULL, 3, 1, 'ACDEBFGH'),
(NULL, 3, NULL, 'ACDEFBGH');
2019-06-03 17:36:27 +00:00
SELECT col1, col2, col3, count() FROM test1_00395 GROUP BY col1, col2, col3 ORDER BY col1, col2, col3;
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395(col1 Array(Nullable(UInt8)), col2 String) ENGINE=TinyLog;
2024-08-08 10:30:40 +00:00
INSERT INTO test1_00395(col1,col2) VALUES([0], 'ABCDEFGH'),
([0], 'BACDEFGH'),
([1], 'BCADEFGH'),
([1], 'BCDAEFGH'),
([1], 'BCDEAFGH'),
([1], 'BCDEFAGH'),
([1], 'BCDEFGAH'),
([1], 'BCDEFGHA'),
([1], 'ACBDEFGH'),
([NULL], 'ACDBEFGH'),
([NULL], 'ACDEBFGH'),
([NULL], 'ACDEFBGH');
2019-06-03 17:36:27 +00:00
SELECT col1, count() FROM test1_00395 GROUP BY col1 ORDER BY col1;
DROP TABLE IF EXISTS test1_00395;
2019-06-07 16:09:21 +00:00
DROP TABLE test2;