From b1e055686e58b0b47c2d1af619c9e2ff082aee51 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Fri, 26 Jun 2020 02:52:26 +0300 Subject: [PATCH 1/2] Added tests for #8692 --- .../01345_array_join_LittleMaverick.reference | 2 ++ .../01345_array_join_LittleMaverick.sql | 28 +++++++++++++++++++ .../01346_array_join_mrxotey.reference | 2 ++ .../0_stateless/01346_array_join_mrxotey.sql | 28 +++++++++++++++++++ 4 files changed, 60 insertions(+) create mode 100644 tests/queries/0_stateless/01345_array_join_LittleMaverick.reference create mode 100644 tests/queries/0_stateless/01345_array_join_LittleMaverick.sql create mode 100644 tests/queries/0_stateless/01346_array_join_mrxotey.reference create mode 100644 tests/queries/0_stateless/01346_array_join_mrxotey.sql diff --git a/tests/queries/0_stateless/01345_array_join_LittleMaverick.reference b/tests/queries/0_stateless/01345_array_join_LittleMaverick.reference new file mode 100644 index 00000000000..83fdd14d0c8 --- /dev/null +++ b/tests/queries/0_stateless/01345_array_join_LittleMaverick.reference @@ -0,0 +1,2 @@ +NEW 2 +\N 2 diff --git a/tests/queries/0_stateless/01345_array_join_LittleMaverick.sql b/tests/queries/0_stateless/01345_array_join_LittleMaverick.sql new file mode 100644 index 00000000000..6529f51471e --- /dev/null +++ b/tests/queries/0_stateless/01345_array_join_LittleMaverick.sql @@ -0,0 +1,28 @@ +DROP TABLE IF EXISTS test; + +CREATE TABLE test +( + `id` Nullable(String), + `status` Nullable(Enum8('NEW' = 0, 'CANCEL' = 1)), + `nested.nestedType` Array(Nullable(String)), + `partition` Date +) ENGINE = MergeTree() PARTITION BY partition +ORDER BY + partition SETTINGS index_granularity = 8192; + +INSERT INTO test VALUES ('1', 'NEW', array('a', 'b'), now()); + +SELECT + status, + count() AS all +FROM test ARRAY JOIN nested as nestedJoined +WHERE (status IN ( + SELECT status + FROM temp.test ARRAY JOIN nested as nestedJoined + GROUP BY status + ORDER BY count() DESC + LIMIT 10)) AND (id IN ('1', '2')) +GROUP BY CUBE(status) +LIMIT 100; + +DROP TABLE test; diff --git a/tests/queries/0_stateless/01346_array_join_mrxotey.reference b/tests/queries/0_stateless/01346_array_join_mrxotey.reference new file mode 100644 index 00000000000..6ed281c757a --- /dev/null +++ b/tests/queries/0_stateless/01346_array_join_mrxotey.reference @@ -0,0 +1,2 @@ +1 +1 diff --git a/tests/queries/0_stateless/01346_array_join_mrxotey.sql b/tests/queries/0_stateless/01346_array_join_mrxotey.sql new file mode 100644 index 00000000000..b57b7fadcdd --- /dev/null +++ b/tests/queries/0_stateless/01346_array_join_mrxotey.sql @@ -0,0 +1,28 @@ +DROP TABLE IF EXISTS test; + +CREATE TABLE test ( + a Date, + b UInt32, + c UInt64, + p Nested ( + at1 String, + at2 String + ) +) ENGINE = MergeTree() +PARTITION BY a +ORDER BY b +SETTINGS index_granularity = 8192; + +INSERT INTO test (a, b, c, p.at1, p.at2) +VALUES (now(), 1, 2, ['foo', 'bar'], ['baz', 'qux']); + +SELECT b +FROM test +ARRAY JOIN p +WHERE + b = 1 + AND c IN ( + SELECT c FROM test + ); + +DROP TABLE test; From 2a1937625b0abf0ed8244c90284af15b57e8814e Mon Sep 17 00:00:00 2001 From: alexey-milovidov Date: Fri, 26 Jun 2020 13:23:14 +0300 Subject: [PATCH 2/2] Update 01345_array_join_LittleMaverick.sql --- tests/queries/0_stateless/01345_array_join_LittleMaverick.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/queries/0_stateless/01345_array_join_LittleMaverick.sql b/tests/queries/0_stateless/01345_array_join_LittleMaverick.sql index 6529f51471e..ba6842886d8 100644 --- a/tests/queries/0_stateless/01345_array_join_LittleMaverick.sql +++ b/tests/queries/0_stateless/01345_array_join_LittleMaverick.sql @@ -18,7 +18,7 @@ SELECT FROM test ARRAY JOIN nested as nestedJoined WHERE (status IN ( SELECT status - FROM temp.test ARRAY JOIN nested as nestedJoined + FROM test ARRAY JOIN nested as nestedJoined GROUP BY status ORDER BY count() DESC LIMIT 10)) AND (id IN ('1', '2'))