From 8d2122c62c4d00a99067202e366dd53d02f01571 Mon Sep 17 00:00:00 2001 From: Artem Zuikov Date: Tue, 25 Aug 2020 15:46:31 +0300 Subject: [PATCH] add test --- ...t_optimizations_over_distributed.reference | 12 ++++++++ ...456_ast_optimizations_over_distributed.sql | 28 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/queries/0_stateless/01456_ast_optimizations_over_distributed.reference create mode 100644 tests/queries/0_stateless/01456_ast_optimizations_over_distributed.sql diff --git a/tests/queries/0_stateless/01456_ast_optimizations_over_distributed.reference b/tests/queries/0_stateless/01456_ast_optimizations_over_distributed.reference new file mode 100644 index 00000000000..8c76b239991 --- /dev/null +++ b/tests/queries/0_stateless/01456_ast_optimizations_over_distributed.reference @@ -0,0 +1,12 @@ +1 +1 +1 +other +google +1 +1 +2 +other +other +google +google diff --git a/tests/queries/0_stateless/01456_ast_optimizations_over_distributed.sql b/tests/queries/0_stateless/01456_ast_optimizations_over_distributed.sql new file mode 100644 index 00000000000..1470d8c8d4f --- /dev/null +++ b/tests/queries/0_stateless/01456_ast_optimizations_over_distributed.sql @@ -0,0 +1,28 @@ +SET optimize_move_functions_out_of_any = 1; +SET optimize_injective_functions_inside_uniq = 1; +SET optimize_arithmetic_operations_in_aggregate_functions = 1; +SET optimize_if_transform_strings_to_enum = 1; + +SELECT any(number + 1) FROM numbers(1); +SELECT uniq(bitNot(number)) FROM numbers(1); +SELECT sum(number + 1) FROM numbers(1); +SELECT transform(number, [1, 2], ['google', 'yandex'], 'other') FROM numbers(1); +SELECT number > 0 ? 'yandex' : 'google' FROM numbers(1); + + +DROP TABLE IF EXISTS local_table; +DROP TABLE IF EXISTS dist; + +CREATE TABLE local_table (number UInt64) ENGINE = Memory; +CREATE TABLE dist AS local_table ENGINE = Distributed(test_cluster_two_shards_localhost, currentDatabase(), local_table); + +INSERT INTO local_table SELECT number FROM numbers(1); + +SELECT any(number + 1) FROM dist; +SELECT uniq(bitNot(number)) FROM dist; +SELECT sum(number + 1) FROM dist; +SELECT transform(number, [1, 2], ['google', 'yandex'], 'other') FROM dist; +SELECT number > 0 ? 'yandex' : 'google' FROM dist; + +DROP TABLE local_table; +DROP TABLE dist;