From 35f0e68892bed172555cfb35ec4a44f34f874308 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 9 Jul 2020 01:41:25 +0300 Subject: [PATCH] Added a test --- .../0_stateless/01388_multi_if_optimization.reference | 4 ++++ tests/queries/0_stateless/01388_multi_if_optimization.sql | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 tests/queries/0_stateless/01388_multi_if_optimization.reference create mode 100644 tests/queries/0_stateless/01388_multi_if_optimization.sql diff --git a/tests/queries/0_stateless/01388_multi_if_optimization.reference b/tests/queries/0_stateless/01388_multi_if_optimization.reference new file mode 100644 index 00000000000..6dbe0f0d96f --- /dev/null +++ b/tests/queries/0_stateless/01388_multi_if_optimization.reference @@ -0,0 +1,4 @@ +SELECT if(number = 1, \'hello\', if(number = 2, \'world\', \'xyz\')) +FROM numbers(10) +SELECT multiIf(number = 1, \'hello\', number = 2, \'world\', \'xyz\') +FROM numbers(10) diff --git a/tests/queries/0_stateless/01388_multi_if_optimization.sql b/tests/queries/0_stateless/01388_multi_if_optimization.sql new file mode 100644 index 00000000000..345fcfb6fcc --- /dev/null +++ b/tests/queries/0_stateless/01388_multi_if_optimization.sql @@ -0,0 +1,5 @@ +-- If you are reading this test please note that as of now this setting does not provide benefits in most of the cases. +SET optimize_if_chain_to_multiif = 0; +EXPLAIN SYNTAX SELECT number = 1 ? 'hello' : (number = 2 ? 'world' : 'xyz') FROM numbers(10); +SET optimize_if_chain_to_multiif = 1; +EXPLAIN SYNTAX SELECT number = 1 ? 'hello' : (number = 2 ? 'world' : 'xyz') FROM numbers(10);