From a3944624a05b75c5061048d8fdc61417d67b846a Mon Sep 17 00:00:00 2001 From: Ivan Lezhankin Date: Fri, 13 Sep 2019 14:10:41 +0300 Subject: [PATCH 1/8] Add test --- .../01009_global_array_join_names.reference | 1 + .../01009_global_array_join_names.sql | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 dbms/tests/queries/0_stateless/01009_global_array_join_names.reference create mode 100644 dbms/tests/queries/0_stateless/01009_global_array_join_names.sql diff --git a/dbms/tests/queries/0_stateless/01009_global_array_join_names.reference b/dbms/tests/queries/0_stateless/01009_global_array_join_names.reference new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/dbms/tests/queries/0_stateless/01009_global_array_join_names.reference @@ -0,0 +1 @@ +1 diff --git a/dbms/tests/queries/0_stateless/01009_global_array_join_names.sql b/dbms/tests/queries/0_stateless/01009_global_array_join_names.sql new file mode 100644 index 00000000000..17e5692c51d --- /dev/null +++ b/dbms/tests/queries/0_stateless/01009_global_array_join_names.sql @@ -0,0 +1,19 @@ +DROP TABLE IF EXISTS test1; +DROP TABLE IF EXISTS test2; + +CREATE TABLE test1 (a UInt8, b Array(DateTime)) ENGINE Memory; +CREATE TABLE test2 as test1 ENGINE Distributed(test_shard, currentDatabase(), test1); + +INSERT INTO test1 VALUES (1, [1, 2, 3]); + +SELECT 1 +FROM d1 AS d1 +ARRAY JOIN arrayFilter(t -> (t GLOBAL IN + ( + SELECT DISTINCT now() AS `ym:a` + WHERE 1 + )), d1.a) AS d1_a +WHERE 1; + +DROP TABLE test1; +DROP TABLE test2; From dc49303baf862e141eadcc539f97fca499d529df Mon Sep 17 00:00:00 2001 From: Ivan Lezhankin Date: Fri, 13 Sep 2019 16:25:24 +0300 Subject: [PATCH 2/8] Use existing alias as external table name --- dbms/src/Interpreters/GlobalSubqueriesVisitor.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/dbms/src/Interpreters/GlobalSubqueriesVisitor.h b/dbms/src/Interpreters/GlobalSubqueriesVisitor.h index 926e6afd1c2..6c380162af4 100644 --- a/dbms/src/Interpreters/GlobalSubqueriesVisitor.h +++ b/dbms/src/Interpreters/GlobalSubqueriesVisitor.h @@ -78,12 +78,16 @@ public: return; } - /// Generate the name for the external table. - String external_table_name = "_data" + toString(external_table_id); - while (external_tables.count(external_table_name)) + String external_table_name = subquery_or_table_name->tryGetAlias(); + if (external_table_name.empty()) { - ++external_table_id; + /// Generate the name for the external table. external_table_name = "_data" + toString(external_table_id); + while (external_tables.count(external_table_name)) + { + ++external_table_id; + external_table_name = "_data" + toString(external_table_id); + } } auto interpreter = interpretSubquery(subquery_or_table_name, context, subquery_depth, {}); From add919e922f014daf770fb62ef76b2afe7cbf0af Mon Sep 17 00:00:00 2001 From: Ivan <5627721+abyss7@users.noreply.github.com> Date: Fri, 13 Sep 2019 17:44:04 +0300 Subject: [PATCH 3/8] Update 01009_global_array_join_names.sql --- .../tests/queries/0_stateless/01009_global_array_join_names.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbms/tests/queries/0_stateless/01009_global_array_join_names.sql b/dbms/tests/queries/0_stateless/01009_global_array_join_names.sql index 17e5692c51d..51447c7708f 100644 --- a/dbms/tests/queries/0_stateless/01009_global_array_join_names.sql +++ b/dbms/tests/queries/0_stateless/01009_global_array_join_names.sql @@ -2,7 +2,7 @@ DROP TABLE IF EXISTS test1; DROP TABLE IF EXISTS test2; CREATE TABLE test1 (a UInt8, b Array(DateTime)) ENGINE Memory; -CREATE TABLE test2 as test1 ENGINE Distributed(test_shard, currentDatabase(), test1); +CREATE TABLE test2 as test1 ENGINE Distributed(test_shard_localhost, currentDatabase(), test1); INSERT INTO test1 VALUES (1, [1, 2, 3]); From d697f4a1d11eec0a6da5d8a8502b10278245e346 Mon Sep 17 00:00:00 2001 From: Ivan <5627721+abyss7@users.noreply.github.com> Date: Fri, 13 Sep 2019 19:07:54 +0300 Subject: [PATCH 4/8] Update 01009_global_array_join_names.sql --- .../queries/0_stateless/01009_global_array_join_names.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbms/tests/queries/0_stateless/01009_global_array_join_names.sql b/dbms/tests/queries/0_stateless/01009_global_array_join_names.sql index 51447c7708f..4f3e24298d6 100644 --- a/dbms/tests/queries/0_stateless/01009_global_array_join_names.sql +++ b/dbms/tests/queries/0_stateless/01009_global_array_join_names.sql @@ -7,12 +7,12 @@ CREATE TABLE test2 as test1 ENGINE Distributed(test_shard_localhost, currentData INSERT INTO test1 VALUES (1, [1, 2, 3]); SELECT 1 -FROM d1 AS d1 +FROM test2 AS test2 ARRAY JOIN arrayFilter(t -> (t GLOBAL IN ( SELECT DISTINCT now() AS `ym:a` WHERE 1 - )), d1.a) AS d1_a + )), test1.b) AS test1_b WHERE 1; DROP TABLE test1; From 33e6681c90aa8fd4ce24df1eb753c46fae0b7cd1 Mon Sep 17 00:00:00 2001 From: Ivan <5627721+abyss7@users.noreply.github.com> Date: Fri, 13 Sep 2019 23:00:28 +0300 Subject: [PATCH 5/8] Update 01009_global_array_join_names.sql --- .../tests/queries/0_stateless/01009_global_array_join_names.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbms/tests/queries/0_stateless/01009_global_array_join_names.sql b/dbms/tests/queries/0_stateless/01009_global_array_join_names.sql index 4f3e24298d6..f3cbd0cf44d 100644 --- a/dbms/tests/queries/0_stateless/01009_global_array_join_names.sql +++ b/dbms/tests/queries/0_stateless/01009_global_array_join_names.sql @@ -12,7 +12,7 @@ ARRAY JOIN arrayFilter(t -> (t GLOBAL IN ( SELECT DISTINCT now() AS `ym:a` WHERE 1 - )), test1.b) AS test1_b + )), test2.b) AS test2_b WHERE 1; DROP TABLE test1; From 8fcf490bd9fa07ec28c702c82ba8b3b628460b36 Mon Sep 17 00:00:00 2001 From: Ivan <5627721+abyss7@users.noreply.github.com> Date: Sat, 14 Sep 2019 00:58:39 +0300 Subject: [PATCH 6/8] Update 01009_global_array_join_names.reference --- .../queries/0_stateless/01009_global_array_join_names.reference | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbms/tests/queries/0_stateless/01009_global_array_join_names.reference b/dbms/tests/queries/0_stateless/01009_global_array_join_names.reference index d00491fd7e5..8b137891791 100644 --- a/dbms/tests/queries/0_stateless/01009_global_array_join_names.reference +++ b/dbms/tests/queries/0_stateless/01009_global_array_join_names.reference @@ -1 +1 @@ -1 + From 66d6e0cbb398ae26afe71eb481f085916acf8b37 Mon Sep 17 00:00:00 2001 From: Ivan <5627721+abyss7@users.noreply.github.com> Date: Sat, 14 Sep 2019 00:59:15 +0300 Subject: [PATCH 7/8] Update 01009_global_array_join_names.reference --- .../queries/0_stateless/01009_global_array_join_names.reference | 1 - 1 file changed, 1 deletion(-) diff --git a/dbms/tests/queries/0_stateless/01009_global_array_join_names.reference b/dbms/tests/queries/0_stateless/01009_global_array_join_names.reference index 8b137891791..e69de29bb2d 100644 --- a/dbms/tests/queries/0_stateless/01009_global_array_join_names.reference +++ b/dbms/tests/queries/0_stateless/01009_global_array_join_names.reference @@ -1 +0,0 @@ - From 782e2b7c6ac67bc45a8d5b4e26b2fb97cf0edafb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=ED=98=84=EC=9A=B0?= Date: Sun, 15 Sep 2019 14:06:22 +0900 Subject: [PATCH 8/8] Fixed typo (#6942) --- CHANGELOG.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d6714b6474..a07fa7507b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -372,7 +372,7 @@ It allows to set commit mode: after every batch of messages is handled, or after * Renamed functions `leastSqr` to `simpleLinearRegression`, `LinearRegression` to `linearRegression`, `LogisticRegression` to `logisticRegression`. [#5391](https://github.com/yandex/ClickHouse/pull/5391) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) ### Performance Improvements -* Paralellize processing of parts of non-replicated MergeTree tables in ALTER MODIFY query. [#4639](https://github.com/yandex/ClickHouse/pull/4639) ([Ivan Kush](https://github.com/IvanKush)) +* Parallelize processing of parts of non-replicated MergeTree tables in ALTER MODIFY query. [#4639](https://github.com/yandex/ClickHouse/pull/4639) ([Ivan Kush](https://github.com/IvanKush)) * Optimizations in regular expressions extraction. [#5193](https://github.com/yandex/ClickHouse/pull/5193) [#5191](https://github.com/yandex/ClickHouse/pull/5191) ([Danila Kutenin](https://github.com/danlark1)) * Do not add right join key column to join result if it's used only in join on section. [#5260](https://github.com/yandex/ClickHouse/pull/5260) ([Artem Zuikov](https://github.com/4ertus2)) * Freeze the Kafka buffer after first empty response. It avoids multiple invokations of `ReadBuffer::next()` for empty result in some row-parsing streams. [#5283](https://github.com/yandex/ClickHouse/pull/5283) ([Ivan](https://github.com/abyss7)) @@ -599,7 +599,7 @@ lee](https://github.com/neverlee)) * Fix error `Unknown log entry type: 0` after `OPTIMIZE TABLE FINAL` query. [#4683](https://github.com/yandex/ClickHouse/pull/4683) ([Amos Bird](https://github.com/amosbird)) * Wrong arguments to `hasAny` or `hasAll` functions may lead to segfault. [#4698](https://github.com/yandex/ClickHouse/pull/4698) ([alexey-milovidov](https://github.com/alexey-milovidov)) * Deadlock may happen while executing `DROP DATABASE dictionary` query. [#4701](https://github.com/yandex/ClickHouse/pull/4701) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fix undefinied behavior in `median` and `quantile` functions. [#4702](https://github.com/yandex/ClickHouse/pull/4702) ([hcz](https://github.com/hczhcz)) +* Fix undefined behavior in `median` and `quantile` functions. [#4702](https://github.com/yandex/ClickHouse/pull/4702) ([hcz](https://github.com/hczhcz)) * Fix compression level detection when `network_compression_method` in lowercase. Broken in v19.1. [#4706](https://github.com/yandex/ClickHouse/pull/4706) ([proller](https://github.com/proller)) * Fixed ignorance of `UTC` setting (fixes issue [#4658](https://github.com/yandex/ClickHouse/issues/4658)). [#4718](https://github.com/yandex/ClickHouse/pull/4718) ([proller](https://github.com/proller)) * Fix `histogram` function behaviour with `Distributed` tables. [#4741](https://github.com/yandex/ClickHouse/pull/4741) ([olegkv](https://github.com/olegkv)) @@ -668,7 +668,7 @@ lee](https://github.com/neverlee)) * Fix error `Unknown log entry type: 0` after `OPTIMIZE TABLE FINAL` query. [#4683](https://github.com/yandex/ClickHouse/pull/4683) ([Amos Bird](https://github.com/amosbird)) * Wrong arguments to `hasAny` or `hasAll` functions may lead to segfault. [#4698](https://github.com/yandex/ClickHouse/pull/4698) ([alexey-milovidov](https://github.com/alexey-milovidov)) * Deadlock may happen while executing `DROP DATABASE dictionary` query. [#4701](https://github.com/yandex/ClickHouse/pull/4701) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fix undefinied behavior in `median` and `quantile` functions. [#4702](https://github.com/yandex/ClickHouse/pull/4702) ([hcz](https://github.com/hczhcz)) +* Fix undefined behavior in `median` and `quantile` functions. [#4702](https://github.com/yandex/ClickHouse/pull/4702) ([hcz](https://github.com/hczhcz)) * Fix compression level detection when `network_compression_method` in lowercase. Broken in v19.1. [#4706](https://github.com/yandex/ClickHouse/pull/4706) ([proller](https://github.com/proller)) * Fixed ignorance of `UTC` setting (fixes issue [#4658](https://github.com/yandex/ClickHouse/issues/4658)). [#4718](https://github.com/yandex/ClickHouse/pull/4718) ([proller](https://github.com/proller)) * Fix `histogram` function behaviour with `Distributed` tables. [#4741](https://github.com/yandex/ClickHouse/pull/4741) ([olegkv](https://github.com/olegkv)) @@ -850,7 +850,7 @@ lee](https://github.com/neverlee)) * Added aggregate function `entropy` which computes Shannon entropy. [#4238](https://github.com/yandex/ClickHouse/pull/4238) ([Quid37](https://github.com/Quid37)) * Added ability to send queries `INSERT INTO tbl VALUES (....` to server without splitting on `query` and `data` parts. [#4301](https://github.com/yandex/ClickHouse/pull/4301) ([alesapin](https://github.com/alesapin)) * Generic implementation of `arrayWithConstant` function was added. [#4322](https://github.com/yandex/ClickHouse/pull/4322) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Implented `NOT BETWEEN` comparison operator. [#4228](https://github.com/yandex/ClickHouse/pull/4228) ([Dmitry Naumov](https://github.com/nezed)) +* Implemented `NOT BETWEEN` comparison operator. [#4228](https://github.com/yandex/ClickHouse/pull/4228) ([Dmitry Naumov](https://github.com/nezed)) * Implement `sumMapFiltered` in order to be able to limit the number of keys for which values will be summed by `sumMap`. [#4129](https://github.com/yandex/ClickHouse/pull/4129) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) * Added support of `Nullable` types in `mysql` table function. [#4198](https://github.com/yandex/ClickHouse/pull/4198) ([Emmanuel Donin de Rosière](https://github.com/edonin)) * Support for arbitrary constant expressions in `LIMIT` clause. [#4246](https://github.com/yandex/ClickHouse/pull/4246) ([k3box](https://github.com/k3box)) @@ -925,7 +925,7 @@ lee](https://github.com/neverlee)) * Added keyword `INDEX` in `CREATE TABLE` query. A column with name `index` must be quoted with backticks or double quotes: `` `index` ``. [#4143](https://github.com/yandex/ClickHouse/pull/4143) ([Nikita Vasilev](https://github.com/nikvas0)) * `sumMap` now promote result type instead of overflow. The old `sumMap` behavior can be obtained by using `sumMapWithOverflow` function. [#4151](https://github.com/yandex/ClickHouse/pull/4151) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) -### Performance Impovements +### Performance Improvements * `std::sort` replaced by `pdqsort` for queries without `LIMIT`. [#4236](https://github.com/yandex/ClickHouse/pull/4236) ([Evgenii Pravda](https://github.com/kvinty)) * Now server reuse threads from global thread pool. This affects performance in some corner cases. [#4150](https://github.com/yandex/ClickHouse/pull/4150) ([alexey-milovidov](https://github.com/alexey-milovidov))