Test materialize() on sparse columns

This commit is contained in:
Alexander Gololobov 2024-09-10 14:17:57 +02:00
parent db42cf12fd
commit 41aaf07537
2 changed files with 102 additions and 0 deletions

View File

@ -0,0 +1,50 @@
-- { echoOn }
SELECT dumpColumnStructure(id) FROM sparse_t;
UInt64, Sparse(size = 2, UInt64(size = 2), UInt64(size = 1))
UInt64, Sparse(size = 2, UInt64(size = 2), UInt64(size = 1))
SELECT dumpColumnStructure(materialize(id)) FROM sparse_t;
UInt64, UInt64(size = 2)
UInt64, UInt64(size = 2)
SELECT dumpColumnStructure(u) FROM sparse_t;
UInt64, Sparse(size = 2, UInt64(size = 1), UInt64(size = 0))
UInt64, Sparse(size = 2, UInt64(size = 1), UInt64(size = 0))
SELECT dumpColumnStructure(materialize(u)) FROM sparse_t;
UInt64, UInt64(size = 2)
UInt64, UInt64(size = 2)
SELECT dumpColumnStructure(s) FROM sparse_t;
String, Sparse(size = 2, String(size = 2), UInt64(size = 1))
String, Sparse(size = 2, String(size = 2), UInt64(size = 1))
SELECT dumpColumnStructure(materialize(s)) FROM sparse_t;
String, String(size = 2)
String, String(size = 2)
SELECT dumpColumnStructure(arr1) FROM sparse_t;
Array(String), Array(size = 2, UInt64(size = 2), String(size = 1))
Array(String), Array(size = 2, UInt64(size = 2), String(size = 1))
SELECT dumpColumnStructure(materialize(arr1)) FROM sparse_t;
Array(String), Array(size = 2, UInt64(size = 2), String(size = 1))
Array(String), Array(size = 2, UInt64(size = 2), String(size = 1))
SELECT dumpColumnStructure(arr2) FROM sparse_t;
Array(UInt64), Array(size = 2, UInt64(size = 2), UInt64(size = 1))
Array(UInt64), Array(size = 2, UInt64(size = 2), UInt64(size = 1))
SELECT dumpColumnStructure(materialize(arr2)) FROM sparse_t;
Array(UInt64), Array(size = 2, UInt64(size = 2), UInt64(size = 1))
Array(UInt64), Array(size = 2, UInt64(size = 2), UInt64(size = 1))
SELECT dumpColumnStructure(t) FROM sparse_t;
Tuple(a UInt64, s String), Tuple(size = 2, Sparse(size = 2, UInt64(size = 1), UInt64(size = 0)), Sparse(size = 2, String(size = 1), UInt64(size = 0)))
Tuple(a UInt64, s String), Tuple(size = 2, Sparse(size = 2, UInt64(size = 1), UInt64(size = 0)), Sparse(size = 2, String(size = 1), UInt64(size = 0)))
SELECT dumpColumnStructure(materialize(t)) FROM sparse_t;
Tuple(a UInt64, s String), Tuple(size = 2, UInt64(size = 2), String(size = 2))
Tuple(a UInt64, s String), Tuple(size = 2, UInt64(size = 2), String(size = 2))
SELECT dumpColumnStructure(t.a) FROM sparse_t;
UInt64, Sparse(size = 2, UInt64(size = 1), UInt64(size = 0))
UInt64, Sparse(size = 2, UInt64(size = 1), UInt64(size = 0))
SELECT dumpColumnStructure(materialize(t.a)) FROM sparse_t;
UInt64, UInt64(size = 2)
UInt64, UInt64(size = 2)
SELECT dumpColumnStructure(t.s) FROM sparse_t;
String, Sparse(size = 2, String(size = 1), UInt64(size = 0))
String, Sparse(size = 2, String(size = 1), UInt64(size = 0))
SELECT dumpColumnStructure(materialize(t.s)) FROM sparse_t;
String, String(size = 2)
String, String(size = 2)

View File

@ -0,0 +1,52 @@
DROP TABLE IF EXISTS sparse_t;
CREATE TABLE sparse_t (
id UInt64,
u UInt64,
s String,
arr1 Array(String),
arr2 Array(UInt64),
t Tuple(a UInt64, s String))
ENGINE = MergeTree ORDER BY tuple()
SETTINGS ratio_of_defaults_for_sparse_serialization = 0.1;
INSERT INTO sparse_t SELECT
number,
if (number % 2 = 0, number, 0),
if (number % 2 = 0, toString(number), ''),
if (number % 2 = 0, [''], []),
if (number % 2 = 0, [0], []),
(if (number % 2 = 0, number, 0), '')
FROM numbers(2);
-- { echoOn }
SELECT dumpColumnStructure(id) FROM sparse_t;
SELECT dumpColumnStructure(materialize(id)) FROM sparse_t;
SELECT dumpColumnStructure(u) FROM sparse_t;
SELECT dumpColumnStructure(materialize(u)) FROM sparse_t;
SELECT dumpColumnStructure(s) FROM sparse_t;
SELECT dumpColumnStructure(materialize(s)) FROM sparse_t;
SELECT dumpColumnStructure(arr1) FROM sparse_t;
SELECT dumpColumnStructure(materialize(arr1)) FROM sparse_t;
SELECT dumpColumnStructure(arr2) FROM sparse_t;
SELECT dumpColumnStructure(materialize(arr2)) FROM sparse_t;
SELECT dumpColumnStructure(t) FROM sparse_t;
SELECT dumpColumnStructure(materialize(t)) FROM sparse_t;
SELECT dumpColumnStructure(t.a) FROM sparse_t;
SELECT dumpColumnStructure(materialize(t.a)) FROM sparse_t;
SELECT dumpColumnStructure(t.s) FROM sparse_t;
SELECT dumpColumnStructure(materialize(t.s)) FROM sparse_t;
-- { echoOff }
DROP TABLE IF EXISTS sparse_t
;