This commit is contained in:
Nikita Fomichev 2024-11-20 17:56:06 -05:00 committed by GitHub
commit 597fc6823d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,37 @@
a
a
a
b
xx
xx
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
---
4
xx
xx
a 2020-01-01 00:00:00.000
a 2020-01-01 10:10:10.000
a 2020-01-01 10:10:10.110
a 1
a 1
a 1
a a
a a
a b
a \N
a \N
a \N
a \N
a \N
z a

View File

@ -0,0 +1,23 @@
set allow_experimental_variant_type = 1;
CREATE OR REPLACE TABLE test(
key String,
val Map(String, Variant(String, Int32, DateTime64(3, 'UTC')))
) engine = ReplicatedMergeTree('/clickhouse/tables/{database}/table', '1')
order by key;
insert into test VALUES ('a', {'a':'a', 'b':1, 'c': '2020-01-01 10:10:10.11'});
insert into test VALUES ('', {'':'xx', '':4});
insert into test VALUES ('', {'x':'xx'});
insert into test VALUES ('', {});
insert into test VALUES ('a', {'a':'a', 'b':1, 'c': '2020-01-01 10:10:10'});
insert into test VALUES ('a', {'a':'b', 'b':1, 'c': '2020-01-01'});
insert into test VALUES ('z', {'a':'a'});
insert into test VALUES ('a', {'a': Null});
insert into test VALUES ('a', {'a': Null, 'a': Null});
insert into test VALUES ('a', {'a': Null, 'c': Null});
SELECT variantElement(arrayJoin(mapValues(val)), 'String') FROM test ORDER BY ALL;
select '---';
SELECT key, arrayJoin(mapValues(val)) FROM test ORDER BY ALL;