mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Add the Analyzer implementation for the RewriteSumFunctionWithSumAndCount
Signed-off-by: Jiebin Sun <jiebin.sun@intel.com>
This commit is contained in:
parent
b6b0711238
commit
dfc8e79511
133
src/Analyzer/Passes/RewriteSumFunctionWithSumAndCountPass.cpp
Normal file
133
src/Analyzer/Passes/RewriteSumFunctionWithSumAndCountPass.cpp
Normal file
@ -0,0 +1,133 @@
|
||||
#include <Analyzer/Passes/RewriteSumFunctionWithSumAndCountPass.h>
|
||||
|
||||
#include <AggregateFunctions/AggregateFunctionFactory.h>
|
||||
#include <Analyzer/InDepthQueryTreeVisitor.h>
|
||||
#include <Analyzer/ColumnNode.h>
|
||||
#include <Analyzer/ConstantNode.h>
|
||||
#include <Analyzer/FunctionNode.h>
|
||||
#include <Functions/FunctionFactory.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
/** Rewrite the following AST to break the function `sum(column + literal)` into two individual functions
|
||||
* `sum(column)` and `literal * count(column)`.
|
||||
* sum(column + literal) -> sum(column) + literal * count(column)
|
||||
* sum(literal + column) -> sum(column) + literal * count(column)
|
||||
* sum(column - literal) -> sum(column) - literal * count(column)
|
||||
* sum(literal - column) -> sum(column) - literal * count(column)
|
||||
*/
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
class RewriteSumFunctionWithSumAndCountVisitor : public InDepthQueryTreeVisitorWithContext<RewriteSumFunctionWithSumAndCountVisitor>
|
||||
{
|
||||
public:
|
||||
using Base = InDepthQueryTreeVisitorWithContext<RewriteSumFunctionWithSumAndCountVisitor>;
|
||||
using Base::Base;
|
||||
|
||||
void enterImpl(QueryTreeNodePtr & node)
|
||||
{
|
||||
static const std::unordered_set<String> nested_func_supported = {
|
||||
"plus",
|
||||
"minus"
|
||||
};
|
||||
|
||||
const auto * function = node->as<FunctionNode>();
|
||||
if (!function || Poco::toLower(function->getFunctionName()) != "sum")
|
||||
return;
|
||||
|
||||
auto & func_node = function->getArguments().getNodes();
|
||||
if (func_node.size() != 1)
|
||||
return;
|
||||
|
||||
const auto * nested_func = func_node[0]->as<FunctionNode>();
|
||||
if (!nested_func || !nested_func_supported.contains(Poco::toLower(nested_func->getFunctionName())))
|
||||
return;
|
||||
|
||||
auto & nested_func_node = nested_func->getArguments().getNodes();
|
||||
if (nested_func_node.size() != 2)
|
||||
return;
|
||||
|
||||
size_t column_id = nested_func_node.size();
|
||||
for (size_t i = 0; i < nested_func_node.size(); i++)
|
||||
{
|
||||
if (const auto * column_node = nested_func_node[i]->as<ColumnNode>())
|
||||
column_id = i;
|
||||
}
|
||||
if (column_id == nested_func_node.size())
|
||||
return;
|
||||
|
||||
size_t literal_id = 1 - column_id;
|
||||
const auto * literal = nested_func_node[literal_id]->as<ConstantNode>();
|
||||
if (!literal || !WhichDataType(literal->getResultType()).isNumber())
|
||||
return;
|
||||
|
||||
const auto * column_node = nested_func_node[column_id]->as<ColumnNode>();
|
||||
if (!column_node)
|
||||
return;
|
||||
|
||||
const auto column_type = column_node->getColumnType();
|
||||
if (!column_type || !isNumber(column_type))
|
||||
return;
|
||||
|
||||
auto column_name = column_node->getColumnName();
|
||||
|
||||
const auto lhs = std::make_shared<FunctionNode>("sum");
|
||||
lhs->getArguments().getNodes().push_back(std::make_shared<ColumnNode>(column_node->getColumn(), column_node->getColumnSource()));
|
||||
resolveAggregateFunctionNode(*lhs, lhs->getArguments().getNodes()[0], lhs->getFunctionName());
|
||||
|
||||
const auto rhs_nested_right = std::make_shared<FunctionNode>("count");
|
||||
rhs_nested_right->getArguments().getNodes().push_back(std::make_shared<ColumnNode>(column_node->getColumn(), column_node->getColumnSource()));
|
||||
resolveAggregateFunctionNode(*rhs_nested_right, rhs_nested_right->getArguments().getNodes()[0], rhs_nested_right->getFunctionName());
|
||||
|
||||
const auto rhs = std::make_shared<FunctionNode>("multiply");
|
||||
rhs->getArguments().getNodes().push_back(std::make_shared<ConstantNode>(literal));
|
||||
rhs->getArguments().getNodes().push_back(rhs_nested_right);
|
||||
resolveOrdinaryFunctionNode(*rhs, rhs->getFunctionName());
|
||||
|
||||
const auto new_node = std::make_shared<FunctionNode>("plus");
|
||||
|
||||
if (column_id == 0)
|
||||
new_node->getArguments().getNodes() = {lhs, rhs};
|
||||
else if (column_id == 1)
|
||||
new_node->getArguments().getNodes() = {rhs, lhs};
|
||||
|
||||
resolveOrdinaryFunctionNode(*new_node, new_node->getFunctionName());
|
||||
|
||||
if (!new_node)
|
||||
return;
|
||||
|
||||
node = new_node;
|
||||
}
|
||||
|
||||
private:
|
||||
void resolveOrdinaryFunctionNode(FunctionNode & function_node, const String & function_name) const
|
||||
{
|
||||
auto function = FunctionFactory::instance().get(function_name, getContext());
|
||||
function_node.resolveAsFunction(function->build(function_node.getArgumentColumns()));
|
||||
}
|
||||
|
||||
static inline void resolveAggregateFunctionNode(FunctionNode & function_node, const QueryTreeNodePtr & argument, const String & aggregate_function_name)
|
||||
{
|
||||
AggregateFunctionProperties properties;
|
||||
auto aggregate_function = AggregateFunctionFactory::instance().get(aggregate_function_name,
|
||||
{ argument->getResultType() },
|
||||
{},
|
||||
properties);
|
||||
|
||||
function_node.resolveAsAggregateFunction(std::move(aggregate_function));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
void RewriteSumFunctionWithSumAndCountPass::run(QueryTreeNodePtr query_tree_node, ContextPtr context)
|
||||
{
|
||||
RewriteSumFunctionWithSumAndCountVisitor visitor(std::move(context));
|
||||
visitor.visit(query_tree_node);
|
||||
}
|
||||
|
||||
}
|
19
src/Analyzer/Passes/RewriteSumFunctionWithSumAndCountPass.h
Normal file
19
src/Analyzer/Passes/RewriteSumFunctionWithSumAndCountPass.h
Normal file
@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <Analyzer/IQueryTreePass.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
class RewriteSumFunctionWithSumAndCountPass final : public IQueryTreePass
|
||||
{
|
||||
public:
|
||||
String getName() override { return "RewriteSumFunctionWithSumAndCountPass"; }
|
||||
|
||||
String getDescription() override { return "Rewrite sum(column +/- literal) into sum(column) and literal * count(column)"; }
|
||||
|
||||
void run(QueryTreeNodePtr query_tree_node, ContextPtr context) override;
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -18,6 +18,7 @@
|
||||
#include <Analyzer/Utils.h>
|
||||
#include <Analyzer/Passes/QueryAnalysisPass.h>
|
||||
#include <Analyzer/Passes/RemoveUnusedProjectionColumnsPass.h>
|
||||
#include <Analyzer/Passes/RewriteSumFunctionWithSumAndCountPass.h>
|
||||
#include <Analyzer/Passes/CountDistinctPass.h>
|
||||
#include <Analyzer/Passes/UniqToCountPass.h>
|
||||
#include <Analyzer/Passes/FunctionToSubcolumnsPass.h>
|
||||
@ -248,6 +249,7 @@ void addQueryTreePasses(QueryTreePassManager & manager)
|
||||
|
||||
manager.addPass(std::make_unique<ConvertLogicalExpressionToCNFPass>());
|
||||
|
||||
manager.addPass(std::make_unique<RewriteSumFunctionWithSumAndCountPass>());
|
||||
manager.addPass(std::make_unique<CountDistinctPass>());
|
||||
manager.addPass(std::make_unique<UniqToCountPass>());
|
||||
manager.addPass(std::make_unique<RewriteAggregateFunctionWithIfPass>());
|
||||
|
@ -17,6 +17,8 @@ void RewriteSumFunctionWithSumAndCountMatcher::visit(ASTPtr & ast, const Data &
|
||||
* `sum(column)` and `literal * count(column)`.
|
||||
* sum(column + literal) -> sum(column) + literal * count(column)
|
||||
* sum(literal + column) -> sum(column) + literal * count(column)
|
||||
* sum(column - literal) -> sum(column) - literal * count(column)
|
||||
* sum(literal - column) -> sum(column) - literal * count(column)
|
||||
*/
|
||||
void RewriteSumFunctionWithSumAndCountMatcher::visit(const ASTFunction & function, ASTPtr & ast, const Data & data)
|
||||
{
|
||||
@ -30,14 +32,16 @@ void RewriteSumFunctionWithSumAndCountMatcher::visit(const ASTFunction & functio
|
||||
|
||||
const auto * nested_func = function.arguments->children[0]->as<ASTFunction>();
|
||||
|
||||
if (!nested_func || !nested_func_supported.contains(Poco::toLower(nested_func->name))|| nested_func->arguments->children.size() != 2)
|
||||
if (!nested_func || !nested_func_supported.contains(Poco::toLower(nested_func->name)) || nested_func->arguments->children.size() != 2)
|
||||
return;
|
||||
|
||||
size_t column_id = nested_func->arguments->children.size();
|
||||
|
||||
for (size_t i = 0; i < nested_func->arguments->children.size(); i++)
|
||||
{
|
||||
if (nested_func->arguments->children[i]->as<ASTIdentifier>())
|
||||
column_id = i;
|
||||
}
|
||||
|
||||
if (column_id == nested_func->arguments->children.size())
|
||||
return;
|
||||
|
@ -754,11 +754,12 @@ void TreeOptimizer::apply(ASTPtr & query, TreeRewriterResult & result,
|
||||
tables_with_columns, result.storage_snapshot->metadata, result.storage);
|
||||
}
|
||||
|
||||
/// Rewrite sum(column +/- literal) function with sum(column) +/- literal * count(column).
|
||||
rewriteSumFunctionWithSumAndCount(query, tables_with_columns);
|
||||
|
||||
/// Rewrite date filters to avoid the calls of converters such as toYear, toYYYYMM, etc.
|
||||
optimizeDateFilters(select_query, tables_with_columns, context);
|
||||
|
||||
rewriteSumFunctionWithSumAndCount(query, tables_with_columns);
|
||||
|
||||
/// GROUP BY injective function elimination.
|
||||
optimizeGroupBy(select_query, context);
|
||||
|
||||
|
@ -8,3 +8,21 @@ FROM
|
||||
WHERE (a > 0) AND (b > 0)
|
||||
HAVING c > 0
|
||||
2
|
||||
SELECT min(n) + 1 AS c
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
WHERE (n + 1) > 0
|
||||
)
|
||||
WHERE ((n + 1) AS a) > 0
|
||||
HAVING c > 0
|
||||
1
|
||||
SELECT min(n) + 1 AS c
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
)
|
||||
HAVING c > 0
|
||||
1
|
||||
|
@ -3,3 +3,9 @@ SET convert_query_to_cnf = 0;
|
||||
|
||||
explain syntax select min((n as a) + (1 as b)) c from (select number n from numbers(10)) where a > 0 and b > 0 having c > 0;
|
||||
select min((n as a) + (1 as b)) c from (select number n from numbers(10)) where a > 0 and b > 0 having c > 0;
|
||||
|
||||
explain syntax select min((n + 1) as a) c from (select number n from numbers(10)) where a > 0 having c > 0;
|
||||
select min((n + 1) as a) c from (select number n from numbers(10)) where a > 0 having c > 0;
|
||||
|
||||
explain syntax select min(n + 1) as c from (select number n from numbers(10)) having c > 0;
|
||||
select min(n + 1) c from (select number n from numbers(10)) having c > 0;
|
||||
|
@ -35,6 +35,9 @@ EXPLAIN SYNTAX SELECT * EXCEPT(i) APPLY(sum) from columns_transformers;
|
||||
EXPLAIN SYNTAX SELECT columns_transformers.* EXCEPT(j) APPLY(avg) from columns_transformers;
|
||||
EXPLAIN SYNTAX SELECT a.* APPLY(toDate) EXCEPT(i, j) APPLY(any) from columns_transformers a;
|
||||
EXPLAIN SYNTAX SELECT * REPLACE(i + 1 AS i) APPLY(sum) from columns_transformers;
|
||||
EXPLAIN AST SELECT * REPLACE(i + 1 AS i) APPLY(sum) from columns_transformers;
|
||||
EXPLAIN SYNTAX SELECT sum(i + 1 AS m) from columns_transformers;
|
||||
EXPLAIN AST SELECT sum(i + 1 AS m) from columns_transformers;
|
||||
EXPLAIN SYNTAX SELECT columns_transformers.* REPLACE(j + 2 AS j, i + 1 AS i) APPLY(avg) from columns_transformers;
|
||||
EXPLAIN SYNTAX SELECT a.* APPLY(toDate) REPLACE(i + 1 AS i) APPLY(any) from columns_transformers a;
|
||||
|
||||
|
@ -1,5 +1,11 @@
|
||||
55
|
||||
55
|
||||
35
|
||||
-35
|
||||
SELECT sum(number) + (1 * count(number))
|
||||
FROM numbers(10)
|
||||
SELECT (1 * count(number)) + sum(number)
|
||||
FROM numbers(10)
|
||||
SELECT sum(number) - (1 * count(number))
|
||||
FROM numbers(10)
|
||||
SELECT (1 * count(number)) - sum(number)
|
||||
@ -39,51 +45,270 @@ FROM test_table
|
||||
WHERE ((uint64 AS m) > 0) AND (n > 0) AND (((m + n) AS i) > 0)
|
||||
HAVING (sum(uint64) + (n * count(uint64))) > 0
|
||||
--
|
||||
20
|
||||
20
|
||||
20
|
||||
20
|
||||
20
|
||||
--
|
||||
SELECT (1 * count(uint64)) + sum(uint64)
|
||||
FROM test_table
|
||||
WHERE ((1 + uint64) AS i) > 0
|
||||
SELECT (1 * count(uint64)) + sum(uint64)
|
||||
FROM test_table
|
||||
HAVING ((1 * count(uint64)) + sum(uint64)) > 0
|
||||
SELECT (1 * count(uint64)) + sum(uint64)
|
||||
FROM test_table
|
||||
WHERE ((1 + uint64) AS i) > 0
|
||||
HAVING ((1 * count(uint64)) + sum(uint64)) > 0
|
||||
SELECT ((1 AS m) * count(uint64)) + sum(uint64)
|
||||
FROM test_table
|
||||
WHERE (m > 0) AND ((uint64 AS n) > 0)
|
||||
HAVING ((m * count(uint64)) + sum(uint64)) > 0
|
||||
SELECT ((1 AS m) * count(uint64)) + sum(uint64)
|
||||
FROM test_table
|
||||
WHERE (m > 0) AND ((uint64 AS n) > 0) AND (((m + n) AS i) > 0)
|
||||
HAVING ((m * count(uint64)) + sum(uint64)) > 0
|
||||
--
|
||||
10
|
||||
10
|
||||
10
|
||||
10
|
||||
10
|
||||
--
|
||||
SELECT sum(uint64) - (1 * count(uint64))
|
||||
FROM test_table
|
||||
WHERE ((uint64 - 1) AS i) > 0
|
||||
SELECT sum(uint64) - (1 * count(uint64))
|
||||
FROM test_table
|
||||
HAVING (sum(uint64) - (1 * count(uint64))) > 0
|
||||
SELECT sum(uint64) - (1 * count(uint64))
|
||||
FROM test_table
|
||||
WHERE ((uint64 - 1) AS i) > 0
|
||||
HAVING (sum(uint64) - (1 * count(uint64))) > 0
|
||||
SELECT sum(uint64) - ((1 AS n) * count(uint64))
|
||||
FROM test_table
|
||||
WHERE ((uint64 AS m) > 0) AND (n > 0)
|
||||
HAVING (sum(uint64) - (n * count(uint64))) > 0
|
||||
SELECT sum(uint64) - ((1 AS n) * count(uint64))
|
||||
FROM test_table
|
||||
WHERE ((uint64 AS m) > 0) AND (n > 0) AND (((m - n) AS i) > 0)
|
||||
HAVING (sum(uint64) - (n * count(uint64))) > 0
|
||||
--
|
||||
-10
|
||||
-10
|
||||
-10
|
||||
-10
|
||||
-10
|
||||
--
|
||||
SELECT (1 * count(uint64)) - sum(uint64)
|
||||
FROM test_table
|
||||
WHERE ((1 - uint64) AS i) > 0
|
||||
SELECT (1 * count(uint64)) - sum(uint64)
|
||||
FROM test_table
|
||||
HAVING ((1 * count(uint64)) - sum(uint64)) < 0
|
||||
SELECT (1 * count(uint64)) - sum(uint64)
|
||||
FROM test_table
|
||||
WHERE ((1 - uint64) AS i) > 0
|
||||
HAVING ((1 * count(uint64)) - sum(uint64)) < 0
|
||||
SELECT ((1 AS m) * count(uint64)) - sum(uint64)
|
||||
FROM test_table
|
||||
WHERE (m > 0) AND ((uint64 AS n) > 0)
|
||||
HAVING ((m * count(uint64)) - sum(uint64)) < 0
|
||||
SELECT ((1 AS m) * count(uint64)) - sum(uint64)
|
||||
FROM test_table
|
||||
WHERE (m > 0) AND ((uint64 AS n) > 0) AND (((m - n) AS i) < 0)
|
||||
HAVING ((m * count(uint64)) - sum(uint64)) < 0
|
||||
--
|
||||
25.549999999999997
|
||||
25.549999999999997
|
||||
4.450000000000001
|
||||
-4.450000000000001
|
||||
25.549999999999997
|
||||
25.549999999999997
|
||||
4.450000000000001
|
||||
-4.450000000000001
|
||||
SELECT sum(uint64) + (2.11 * count(uint64))
|
||||
FROM test_table
|
||||
SELECT (2.11 * count(uint64)) + sum(uint64)
|
||||
FROM test_table
|
||||
SELECT sum(uint64) - (2.11 * count(uint64))
|
||||
FROM test_table
|
||||
SELECT (2.11 * count(uint64)) - sum(uint64)
|
||||
FROM test_table
|
||||
SELECT sum(uint64) + (2.11 * count(uint64))
|
||||
FROM test_table
|
||||
SELECT (2.11 * count(uint64)) + sum(uint64)
|
||||
FROM test_table
|
||||
SELECT sum(uint64) - (2.11 * count(uint64))
|
||||
FROM test_table
|
||||
SELECT (2.11 * count(uint64)) - sum(uint64)
|
||||
FROM test_table
|
||||
--
|
||||
25
|
||||
25
|
||||
5
|
||||
-5
|
||||
25
|
||||
25
|
||||
5
|
||||
-5
|
||||
SELECT sum(uint64) + (2 * count(uint64))
|
||||
FROM test_table
|
||||
SELECT (2 * count(uint64)) + sum(uint64)
|
||||
FROM test_table
|
||||
SELECT sum(uint64) - (2 * count(uint64))
|
||||
FROM test_table
|
||||
SELECT (2 * count(uint64)) - sum(uint64)
|
||||
FROM test_table
|
||||
SELECT sum(uint64) + (2 * count(uint64))
|
||||
FROM test_table
|
||||
SELECT (2 * count(uint64)) + sum(uint64)
|
||||
FROM test_table
|
||||
SELECT sum(uint64) - (2 * count(uint64))
|
||||
FROM test_table
|
||||
SELECT (2 * count(uint64)) - sum(uint64)
|
||||
FROM test_table
|
||||
--
|
||||
26.5
|
||||
26.5
|
||||
6.5
|
||||
-6.5
|
||||
26.5
|
||||
26.5
|
||||
6.5
|
||||
-6.5
|
||||
SELECT sum(float64) + (2 * count(float64))
|
||||
FROM test_table
|
||||
SELECT (2 * count(float64)) + sum(float64)
|
||||
FROM test_table
|
||||
SELECT sum(float64) - (2 * count(float64))
|
||||
FROM test_table
|
||||
SELECT (2 * count(float64)) - sum(float64)
|
||||
FROM test_table
|
||||
SELECT sum(float64) + (2 * count(float64))
|
||||
FROM test_table
|
||||
SELECT (2 * count(float64)) + sum(float64)
|
||||
FROM test_table
|
||||
SELECT sum(float64) - (2 * count(float64))
|
||||
FROM test_table
|
||||
SELECT (2 * count(float64)) - sum(float64)
|
||||
FROM test_table
|
||||
--
|
||||
26.65
|
||||
26.65
|
||||
6.65
|
||||
-6.65
|
||||
26.65
|
||||
26.65
|
||||
6.65
|
||||
-6.65
|
||||
SELECT sum(decimal32) + (2 * count(decimal32))
|
||||
FROM test_table
|
||||
SELECT (2 * count(decimal32)) + sum(decimal32)
|
||||
FROM test_table
|
||||
SELECT sum(decimal32) - (2 * count(decimal32))
|
||||
FROM test_table
|
||||
SELECT (2 * count(decimal32)) - sum(decimal32)
|
||||
FROM test_table
|
||||
SELECT sum(decimal32) + (2 * count(decimal32))
|
||||
FROM test_table
|
||||
SELECT (2 * count(decimal32)) + sum(decimal32)
|
||||
FROM test_table
|
||||
SELECT sum(decimal32) - (2 * count(decimal32))
|
||||
FROM test_table
|
||||
SELECT (2 * count(decimal32)) - sum(decimal32)
|
||||
FROM test_table
|
||||
--
|
||||
55
|
||||
-5
|
||||
5
|
||||
5
|
||||
-5
|
||||
55
|
||||
-5
|
||||
5
|
||||
5
|
||||
-5
|
||||
SELECT (sum(uint64) + (2 * count(uint64))) + (sum(uint64) + (3 * count(uint64)))
|
||||
FROM test_table
|
||||
SELECT ((sum(uint64) + (2 * count(uint64))) + sum(uint64)) + (3 * count(uint64))
|
||||
SELECT (sum(uint64) + (2 * count(uint64))) - (sum(uint64) + (3 * count(uint64)))
|
||||
FROM test_table
|
||||
SELECT (sum(uint64) - (2 * count(uint64))) + (sum(uint64) - (3 * count(uint64)))
|
||||
FROM test_table
|
||||
SELECT (sum(uint64) - (2 * count(uint64))) - (sum(uint64) - (3 * count(uint64)))
|
||||
FROM test_table
|
||||
SELECT ((2 * count(uint64)) - sum(uint64)) - ((3 * count(uint64)) - sum(uint64))
|
||||
FROM test_table
|
||||
SELECT (sum(uint64) + (2 * count(uint64))) + (sum(uint64) + (3 * count(uint64)))
|
||||
FROM test_table
|
||||
SELECT (sum(uint64) + (2 * count(uint64))) - (sum(uint64) + (3 * count(uint64)))
|
||||
FROM test_table
|
||||
SELECT (sum(uint64) - (2 * count(uint64))) + (sum(uint64) - (3 * count(uint64)))
|
||||
FROM test_table
|
||||
SELECT (sum(uint64) - (2 * count(uint64))) - (sum(uint64) - (3 * count(uint64)))
|
||||
FROM test_table
|
||||
SELECT ((2 * count(uint64)) - sum(uint64)) + ((3 * count(uint64)) - sum(uint64))
|
||||
FROM test_table
|
||||
--
|
||||
58
|
||||
-5
|
||||
8
|
||||
5
|
||||
-5
|
||||
58
|
||||
-5
|
||||
8
|
||||
5
|
||||
-8
|
||||
SELECT (sum(float64) + (2 * count(float64))) + (sum(float64) + (3 * count(float64)))
|
||||
FROM test_table
|
||||
SELECT ((sum(float64) + (2 * count(float64))) + sum(float64)) + (3 * count(float64))
|
||||
SELECT (sum(float64) + (2 * count(float64))) - (sum(float64) + (3 * count(float64)))
|
||||
FROM test_table
|
||||
SELECT (sum(float64) - (2 * count(float64))) + (sum(float64) - (3 * count(float64)))
|
||||
FROM test_table
|
||||
SELECT (sum(float64) - (2 * count(float64))) - (sum(float64) - (3 * count(float64)))
|
||||
FROM test_table
|
||||
SELECT ((2 * count(float64)) - sum(float64)) - ((3 * count(float64)) - sum(float64))
|
||||
FROM test_table
|
||||
SELECT (sum(float64) + (2 * count(float64))) + (sum(float64) + (3 * count(float64)))
|
||||
FROM test_table
|
||||
SELECT (sum(float64) + (2 * count(float64))) - (sum(float64) + (3 * count(float64)))
|
||||
FROM test_table
|
||||
SELECT (sum(float64) - (2 * count(float64))) + (sum(float64) - (3 * count(float64)))
|
||||
FROM test_table
|
||||
SELECT (sum(float64) - (2 * count(float64))) - (sum(float64) - (3 * count(float64)))
|
||||
FROM test_table
|
||||
SELECT ((2 * count(float64)) - sum(float64)) + ((3 * count(float64)) - sum(float64))
|
||||
FROM test_table
|
||||
--
|
||||
58.3
|
||||
-5
|
||||
8.3
|
||||
5
|
||||
-5
|
||||
58.3
|
||||
-5
|
||||
8.3
|
||||
5
|
||||
-8.3
|
||||
SELECT (sum(decimal32) + (2 * count(decimal32))) + (sum(decimal32) + (3 * count(decimal32)))
|
||||
FROM test_table
|
||||
SELECT ((sum(decimal32) + (2 * count(decimal32))) + sum(decimal32)) + (3 * count(decimal32))
|
||||
SELECT (sum(decimal32) + (2 * count(decimal32))) - (sum(decimal32) + (3 * count(decimal32)))
|
||||
FROM test_table
|
||||
SELECT (sum(decimal32) - (2 * count(decimal32))) + (sum(decimal32) - (3 * count(decimal32)))
|
||||
FROM test_table
|
||||
SELECT (sum(decimal32) - (2 * count(decimal32))) - (sum(decimal32) - (3 * count(decimal32)))
|
||||
FROM test_table
|
||||
SELECT ((2 * count(decimal32)) - sum(decimal32)) - ((3 * count(decimal32)) - sum(decimal32))
|
||||
FROM test_table
|
||||
SELECT (sum(decimal32) + (2 * count(decimal32))) + (sum(decimal32) + (3 * count(decimal32)))
|
||||
FROM test_table
|
||||
SELECT (sum(decimal32) + (2 * count(decimal32))) - (sum(decimal32) + (3 * count(decimal32)))
|
||||
FROM test_table
|
||||
SELECT (sum(decimal32) - (2 * count(decimal32))) + (sum(decimal32) - (3 * count(decimal32)))
|
||||
FROM test_table
|
||||
SELECT (sum(decimal32) - (2 * count(decimal32))) - (sum(decimal32) - (3 * count(decimal32)))
|
||||
FROM test_table
|
||||
SELECT ((2 * count(decimal32)) - sum(decimal32)) + ((3 * count(decimal32)) - sum(decimal32))
|
||||
FROM test_table
|
||||
|
@ -1,5 +1,9 @@
|
||||
Select sum(number + 1) from numbers(10);
|
||||
Select sum(1 + number) from numbers(10);
|
||||
Select sum(number - 1) from numbers(10);
|
||||
Select sum(1 - number) from numbers(10);
|
||||
EXPLAIN SYNTAX (Select sum(number + 1) from numbers(10));
|
||||
EXPLAIN SYNTAX (Select sum(1 + number) from numbers(10));
|
||||
EXPLAIN SYNTAX (Select sum(number - 1) from numbers(10));
|
||||
EXPLAIN SYNTAX (Select sum(1 - number) from numbers(10));
|
||||
SELECT '--';
|
||||
@ -38,45 +42,180 @@ EXPLAIN SYNTAX (SELECT sum((uint64 AS m) + (1 AS n)) j from test_table where m >
|
||||
EXPLAIN SYNTAX (SELECT sum(((uint64 AS m) + (1 AS n)) AS i) j from test_table where m > 0 and n > 0 and i > 0 having j > 0);
|
||||
SELECT '--';
|
||||
|
||||
SELECT sum(1 + uint64 AS i) from test_table where i > 0;
|
||||
SELECT sum(1 + uint64) AS j from test_table having j > 0;
|
||||
SELECT sum(1 + uint64 AS i) j from test_table where i > 0 having j > 0;
|
||||
SELECT sum((1 AS m) + (uint64 AS n)) j from test_table where m > 0 and n > 0 having j > 0;
|
||||
SELECT sum(((1 AS m) + (uint64 AS n)) AS i) j from test_table where m > 0 and n > 0 and i > 0 having j > 0;
|
||||
SELECT '--';
|
||||
EXPLAIN SYNTAX (SELECT sum(1 + uint64 AS i) from test_table where i > 0);
|
||||
EXPLAIN SYNTAX (SELECT sum(1 + uint64) AS j from test_table having j > 0);
|
||||
EXPLAIN SYNTAX (SELECT sum(1 + uint64 AS i) j from test_table where i > 0 having j > 0);
|
||||
EXPLAIN SYNTAX (SELECT sum((1 AS m) + (uint64 AS n)) j from test_table where m > 0 and n > 0 having j > 0);
|
||||
EXPLAIN SYNTAX (SELECT sum(((1 AS m) + (uint64 AS n)) AS i) j from test_table where m > 0 and n > 0 and i > 0 having j > 0);
|
||||
SELECT '--';
|
||||
|
||||
SELECT sum(uint64 - 1 AS i) from test_table where i > 0;
|
||||
SELECT sum(uint64 - 1) AS j from test_table having j > 0;
|
||||
SELECT sum(uint64 - 1 AS i) j from test_table where i > 0 having j > 0;
|
||||
SELECT sum((uint64 AS m) - (1 AS n)) j from test_table where m > 0 and n > 0 having j > 0;
|
||||
SELECT sum(((uint64 AS m) - (1 AS n)) AS i) j from test_table where m > 0 and n > 0 and i > 0 having j > 0;
|
||||
SELECT '--';
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 - 1 AS i) from test_table where i > 0);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 - 1) AS j from test_table having j > 0);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 - 1 AS i) j from test_table where i > 0 having j > 0);
|
||||
EXPLAIN SYNTAX (SELECT sum((uint64 AS m) - (1 AS n)) j from test_table where m > 0 and n > 0 having j > 0);
|
||||
EXPLAIN SYNTAX (SELECT sum(((uint64 AS m) - (1 AS n)) AS i) j from test_table where m > 0 and n > 0 and i > 0 having j > 0);
|
||||
SELECT '--';
|
||||
|
||||
SELECT sum(1 - uint64 AS i) from test_table;
|
||||
SELECT sum(1 - uint64) AS j from test_table;
|
||||
SELECT sum(1 - uint64 AS i) j from test_table;
|
||||
SELECT sum((1 AS m) - (uint64 AS n)) j from test_table;
|
||||
SELECT sum(((1 AS m) - (uint64 AS n)) AS i) j from test_table;
|
||||
SELECT '--';
|
||||
EXPLAIN SYNTAX (SELECT sum(1 - uint64 AS i) from test_table where i > 0);
|
||||
EXPLAIN SYNTAX (SELECT sum(1 - uint64) AS j from test_table having j < 0);
|
||||
EXPLAIN SYNTAX (SELECT sum(1 - uint64 AS i) j from test_table where i > 0 having j < 0);
|
||||
EXPLAIN SYNTAX (SELECT sum((1 AS m) - (uint64 AS n)) j from test_table where m > 0 and n > 0 having j < 0);
|
||||
EXPLAIN SYNTAX (SELECT sum(((1 AS m) - (uint64 AS n)) AS i) j from test_table where m > 0 and n > 0 and i < 0 having j < 0);
|
||||
SELECT '--';
|
||||
|
||||
SELECT sum(uint64 + 2.11) From test_table;
|
||||
SELECT sum(2.11 + uint64) From test_table;
|
||||
SELECT sum(uint64 - 2.11) From test_table;
|
||||
SELECT sum(2.11 - uint64) From test_table;
|
||||
SELECT sum(uint64) + 2.11 * count(uint64) From test_table;
|
||||
SELECT 2.11 * count(uint64) + sum(uint64) From test_table;
|
||||
SELECT sum(uint64) - 2.11 * count(uint64) From test_table;
|
||||
SELECT 2.11 * count(uint64) - sum(uint64) From test_table;
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 + 2.11) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(2.11 + uint64) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 - 2.11) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(2.11 - uint64) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64) + 2.11 * count(uint64) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT 2.11 * count(uint64) + sum(uint64) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64) - 2.11 * count(uint64) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT 2.11 * count(uint64) - sum(uint64) From test_table);
|
||||
SELECT '--';
|
||||
|
||||
SELECT sum(uint64 + 2) From test_table;
|
||||
SELECT sum(2 + uint64) From test_table;
|
||||
SELECT sum(uint64 - 2) From test_table;
|
||||
SELECT sum(2 - uint64) From test_table;
|
||||
SELECT sum(uint64) + 2 * count(uint64) From test_table;
|
||||
SELECT 2 * count(uint64) + sum(uint64) From test_table;
|
||||
SELECT sum(uint64) - 2 * count(uint64) From test_table;
|
||||
SELECT 2 * count(uint64) - sum(uint64) From test_table;
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 + 2) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(2 + uint64) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 - 2) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(2 - uint64) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64) + 2 * count(uint64) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT 2 * count(uint64) + sum(uint64) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64) - 2 * count(uint64) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT 2 * count(uint64) - sum(uint64) From test_table);
|
||||
SELECT '--';
|
||||
|
||||
SELECT sum(float64 + 2) From test_table;
|
||||
SELECT sum(2 + float64) From test_table;
|
||||
SELECT sum(float64 - 2) From test_table;
|
||||
SELECT sum(2 - float64) From test_table;
|
||||
SELECT sum(float64) + 2 * count(float64) From test_table;
|
||||
SELECT 2 * count(float64) + sum(float64) From test_table;
|
||||
SELECT sum(float64) - 2 * count(float64) From test_table;
|
||||
SELECT 2 * count(float64) - sum(float64) From test_table;
|
||||
EXPLAIN SYNTAX (SELECT sum(float64 + 2) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(2 + float64) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(float64 - 2) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(2 - float64) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(float64) + 2 * count(float64) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT 2 * count(float64) + sum(float64) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(float64) - 2 * count(float64) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT 2 * count(float64) - sum(float64) From test_table);
|
||||
SELECT '--';
|
||||
|
||||
SELECT sum(decimal32 + 2) From test_table;
|
||||
SELECT sum(2 + decimal32) From test_table;
|
||||
SELECT sum(decimal32 - 2) From test_table;
|
||||
SELECT sum(2 - decimal32) From test_table;
|
||||
SELECT sum(decimal32) + 2 * count(decimal32) From test_table;
|
||||
SELECT 2 * count(decimal32) + sum(decimal32) From test_table;
|
||||
SELECT sum(decimal32) - 2 * count(decimal32) From test_table;
|
||||
SELECT 2 * count(decimal32) - sum(decimal32) From test_table;
|
||||
EXPLAIN SYNTAX (SELECT sum(decimal32 + 2) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(2 + decimal32) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(decimal32 - 2) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(2 - decimal32) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(decimal32) + 2 * count(decimal32) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT 2 * count(decimal32) + sum(decimal32) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(decimal32) - 2 * count(decimal32) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT 2 * count(decimal32) - sum(decimal32) From test_table);
|
||||
SELECT '--';
|
||||
|
||||
SELECT sum(uint64 + 2) + sum(uint64 + 3) From test_table;
|
||||
SELECT sum(uint64) + 2 * count(uint64) + sum(uint64) + 3 * count(uint64) From test_table;
|
||||
SELECT sum(uint64 + 2) - sum(uint64 + 3) From test_table;
|
||||
SELECT sum(uint64 - 2) + sum(uint64 - 3) From test_table;
|
||||
SELECT sum(uint64 - 2) - sum(uint64 - 3) From test_table;
|
||||
SELECT sum(2 - uint64) - sum(3 - uint64) From test_table;
|
||||
SELECT (sum(uint64) + 2 * count(uint64)) + (sum(uint64) + 3 * count(uint64)) From test_table;
|
||||
SELECT (sum(uint64) + 2 * count(uint64)) - (sum(uint64) + 3 * count(uint64)) From test_table;
|
||||
SELECT (sum(uint64) - 2 * count(uint64)) + (sum(uint64) - 3 * count(uint64)) From test_table;
|
||||
SELECT (sum(uint64) - 2 * count(uint64)) - (sum(uint64) - 3 * count(uint64)) From test_table;
|
||||
SELECT (2 * count(uint64) - sum(uint64)) + (3 * count(uint64) - sum(uint64)) From test_table;
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 + 2) + sum(uint64 + 3) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64) + 2 * count(uint64) + sum(uint64) + 3 * count(uint64) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 + 2) - sum(uint64 + 3) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 - 2) + sum(uint64 - 3) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 - 2) - sum(uint64 - 3) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(2 - uint64) - sum(3 - uint64) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT (sum(uint64) + 2 * count(uint64)) + (sum(uint64) + 3 * count(uint64)) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT (sum(uint64) + 2 * count(uint64)) - (sum(uint64) + 3 * count(uint64)) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT (sum(uint64) - 2 * count(uint64)) + (sum(uint64) - 3 * count(uint64)) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT (sum(uint64) - 2 * count(uint64)) - (sum(uint64) - 3 * count(uint64)) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT (2 * count(uint64) - sum(uint64)) + (3 * count(uint64) - sum(uint64)) From test_table);
|
||||
SELECT '--';
|
||||
|
||||
SELECT sum(float64 + 2) + sum(float64 + 3) From test_table;
|
||||
SELECT sum(float64) + 2 * count(float64) + sum(float64) + 3 * count(float64) From test_table;
|
||||
SELECT sum(float64 + 2) - sum(float64 + 3) From test_table;
|
||||
SELECT sum(float64 - 2) + sum(float64 - 3) From test_table;
|
||||
SELECT sum(float64 - 2) - sum(float64 - 3) From test_table;
|
||||
SELECT sum(2 - float64) - sum(3 - float64) From test_table;
|
||||
SELECT (sum(float64) + 2 * count(float64)) + (sum(float64) + 3 * count(float64)) From test_table;
|
||||
SELECT (sum(float64) + 2 * count(float64)) - (sum(float64) + 3 * count(float64)) From test_table;
|
||||
SELECT (sum(float64) - 2 * count(float64)) + (sum(float64) - 3 * count(float64)) From test_table;
|
||||
SELECT (sum(float64) - 2 * count(float64)) - (sum(float64) - 3 * count(float64)) From test_table;
|
||||
SELECT (2 * count(float64) - sum(float64)) + (3 * count(float64) - sum(float64)) From test_table;
|
||||
EXPLAIN SYNTAX (SELECT sum(float64 + 2) + sum(float64 + 3) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(float64) + 2 * count(float64) + sum(float64) + 3 * count(float64) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(float64 + 2) - sum(float64 + 3) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(float64 - 2) + sum(float64 - 3) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(float64 - 2) - sum(float64 - 3) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(2 - float64) - sum(3 - float64) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT (sum(float64) + 2 * count(float64)) + (sum(float64) + 3 * count(float64)) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT (sum(float64) + 2 * count(float64)) - (sum(float64) + 3 * count(float64)) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT (sum(float64) - 2 * count(float64)) + (sum(float64) - 3 * count(float64)) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT (sum(float64) - 2 * count(float64)) - (sum(float64) - 3 * count(float64)) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT (2 * count(float64) - sum(float64)) + (3 * count(float64) - sum(float64)) From test_table);
|
||||
SELECT '--';
|
||||
|
||||
SELECT sum(decimal32 + 2) + sum(decimal32 + 3) From test_table;
|
||||
SELECT sum(decimal32) + 2 * count(decimal32) + sum(decimal32) + 3 * count(decimal32) From test_table;
|
||||
SELECT sum(decimal32 + 2) - sum(decimal32 + 3) From test_table;
|
||||
SELECT sum(decimal32 - 2) + sum(decimal32 - 3) From test_table;
|
||||
SELECT sum(decimal32 - 2) - sum(decimal32 - 3) From test_table;
|
||||
SELECT sum(2 - decimal32) - sum(3 - decimal32) From test_table;
|
||||
SELECT (sum(decimal32) + 2 * count(decimal32)) + (sum(decimal32) + 3 * count(decimal32)) From test_table;
|
||||
SELECT (sum(decimal32) + 2 * count(decimal32)) - (sum(decimal32) + 3 * count(decimal32)) From test_table;
|
||||
SELECT (sum(decimal32) - 2 * count(decimal32)) + (sum(decimal32) - 3 * count(decimal32)) From test_table;
|
||||
SELECT (sum(decimal32) - 2 * count(decimal32)) - (sum(decimal32) - 3 * count(decimal32)) From test_table;
|
||||
SELECT (2 * count(decimal32) - sum(decimal32)) + (3 * count(decimal32) - sum(decimal32)) From test_table;
|
||||
EXPLAIN SYNTAX (SELECT sum(decimal32 + 2) + sum(decimal32 + 3) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(decimal32) + 2 * count(decimal32) + sum(decimal32) + 3 * count(decimal32) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(decimal32 + 2) - sum(decimal32 + 3) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(decimal32 - 2) + sum(decimal32 - 3) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(decimal32 - 2) - sum(decimal32 - 3) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT sum(2 - decimal32) - sum(3 - decimal32) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT (sum(decimal32) + 2 * count(decimal32)) + (sum(decimal32) + 3 * count(decimal32)) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT (sum(decimal32) + 2 * count(decimal32)) - (sum(decimal32) + 3 * count(decimal32)) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT (sum(decimal32) - 2 * count(decimal32)) + (sum(decimal32) - 3 * count(decimal32)) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT (sum(decimal32) - 2 * count(decimal32)) - (sum(decimal32) - 3 * count(decimal32)) From test_table);
|
||||
EXPLAIN SYNTAX (SELECT (2 * count(decimal32) - sum(decimal32)) + (3 * count(decimal32) - sum(decimal32)) From test_table);
|
||||
|
||||
DROP TABLE IF EXISTS test_table;
|
||||
|
@ -0,0 +1,401 @@
|
||||
55
|
||||
55
|
||||
55
|
||||
55
|
||||
SELECT sum(number) + (1 * count(number))
|
||||
FROM numbers(10)
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (1 * count(number)) + sum(number)
|
||||
FROM numbers(10)
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT sum(number) - (1 * count(number))
|
||||
FROM numbers(10)
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (1 * count(number)) - sum(number)
|
||||
FROM numbers(10)
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
--
|
||||
\N
|
||||
0
|
||||
WITH CAST(\'1\', \'Nullable(UInt64)\') AS my_literal
|
||||
SELECT sum(number + my_literal)
|
||||
FROM numbers(0)
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
WITH CAST(\'1\', \'Nullable(UInt64)\') AS my_literal
|
||||
SELECT sum(number) + (my_literal * count())
|
||||
FROM numbers(0)
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
--
|
||||
20
|
||||
20
|
||||
20
|
||||
20
|
||||
20
|
||||
--
|
||||
SELECT sum(uint64) + (1 * count(uint64))
|
||||
FROM test_table
|
||||
WHERE ((uint64 + 1) AS i) > 0
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT sum(uint64) + (1 * count(uint64))
|
||||
FROM test_table
|
||||
HAVING (sum(uint64) + (1 * count(uint64))) > 0
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT sum(uint64) + (1 * count(uint64))
|
||||
FROM test_table
|
||||
WHERE ((uint64 + 1) AS i) > 0
|
||||
HAVING (sum(uint64) + (1 * count(uint64))) > 0
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT sum(uint64) + ((1 AS n) * count(uint64))
|
||||
FROM test_table
|
||||
WHERE ((uint64 AS m) > 0) AND (n > 0)
|
||||
HAVING (sum(uint64) + (n * count(uint64))) > 0
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT sum(uint64) + ((1 AS n) * count(uint64))
|
||||
FROM test_table
|
||||
WHERE ((uint64 AS m) > 0) AND (n > 0) AND (((m + n) AS i) > 0)
|
||||
HAVING (sum(uint64) + (n * count(uint64))) > 0
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
--
|
||||
20
|
||||
20
|
||||
20
|
||||
20
|
||||
20
|
||||
--
|
||||
SELECT (1 * count(uint64)) + sum(uint64)
|
||||
FROM test_table
|
||||
WHERE ((1 + uint64) AS i) > 0
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (1 * count(uint64)) + sum(uint64)
|
||||
FROM test_table
|
||||
HAVING ((1 * count(uint64)) + sum(uint64)) > 0
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (1 * count(uint64)) + sum(uint64)
|
||||
FROM test_table
|
||||
WHERE ((1 + uint64) AS i) > 0
|
||||
HAVING ((1 * count(uint64)) + sum(uint64)) > 0
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT ((1 AS m) * count(uint64)) + sum(uint64)
|
||||
FROM test_table
|
||||
WHERE (m > 0) AND ((uint64 AS n) > 0)
|
||||
HAVING ((m * count(uint64)) + sum(uint64)) > 0
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT ((1 AS m) * count(uint64)) + sum(uint64)
|
||||
FROM test_table
|
||||
WHERE (m > 0) AND ((uint64 AS n) > 0) AND (((m + n) AS i) > 0)
|
||||
HAVING ((m * count(uint64)) + sum(uint64)) > 0
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
--
|
||||
18
|
||||
20
|
||||
18
|
||||
20
|
||||
18
|
||||
--
|
||||
SELECT sum(uint64) - (1 * count(uint64))
|
||||
FROM test_table
|
||||
WHERE ((uint64 - 1) AS i) > 0
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT sum(uint64) - (1 * count(uint64))
|
||||
FROM test_table
|
||||
HAVING (sum(uint64) - (1 * count(uint64))) > 0
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT sum(uint64) - (1 * count(uint64))
|
||||
FROM test_table
|
||||
WHERE ((uint64 - 1) AS i) > 0
|
||||
HAVING (sum(uint64) - (1 * count(uint64))) > 0
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT sum(uint64) - ((1 AS n) * count(uint64))
|
||||
FROM test_table
|
||||
WHERE ((uint64 AS m) > 0) AND (n > 0)
|
||||
HAVING (sum(uint64) - (n * count(uint64))) > 0
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT sum(uint64) - ((1 AS n) * count(uint64))
|
||||
FROM test_table
|
||||
WHERE ((uint64 AS m) > 0) AND (n > 0) AND (((m - n) AS i) > 0)
|
||||
HAVING (sum(uint64) - (n * count(uint64))) > 0
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
--
|
||||
20
|
||||
20
|
||||
20
|
||||
20
|
||||
20
|
||||
--
|
||||
SELECT (1 * count(uint64)) - sum(uint64)
|
||||
FROM test_table
|
||||
WHERE ((1 - uint64) AS i) > 0
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (1 * count(uint64)) - sum(uint64)
|
||||
FROM test_table
|
||||
HAVING ((1 * count(uint64)) - sum(uint64)) < 0
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (1 * count(uint64)) - sum(uint64)
|
||||
FROM test_table
|
||||
WHERE ((1 - uint64) AS i) > 0
|
||||
HAVING ((1 * count(uint64)) - sum(uint64)) < 0
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT ((1 AS m) * count(uint64)) - sum(uint64)
|
||||
FROM test_table
|
||||
WHERE (m > 0) AND ((uint64 AS n) > 0)
|
||||
HAVING ((m * count(uint64)) - sum(uint64)) < 0
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT ((1 AS m) * count(uint64)) - sum(uint64)
|
||||
FROM test_table
|
||||
WHERE (m > 0) AND ((uint64 AS n) > 0) AND (((m - n) AS i) < 0)
|
||||
HAVING ((m * count(uint64)) - sum(uint64)) < 0
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
--
|
||||
20
|
||||
20
|
||||
20
|
||||
20
|
||||
25.549999999999997
|
||||
25.549999999999997
|
||||
4.450000000000001
|
||||
-4.450000000000001
|
||||
SELECT sum(uint64) + (2.11 * count(uint64))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (2.11 * count(uint64)) + sum(uint64)
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT sum(uint64) - (2.11 * count(uint64))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (2.11 * count(uint64)) - sum(uint64)
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT sum(uint64) + (2.11 * count(uint64))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (2.11 * count(uint64)) + sum(uint64)
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT sum(uint64) - (2.11 * count(uint64))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (2.11 * count(uint64)) - sum(uint64)
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
--
|
||||
20
|
||||
20
|
||||
20
|
||||
20
|
||||
25
|
||||
25
|
||||
5
|
||||
-5
|
||||
SELECT sum(uint64) + (2 * count(uint64))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (2 * count(uint64)) + sum(uint64)
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT sum(uint64) - (2 * count(uint64))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (2 * count(uint64)) - sum(uint64)
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT sum(uint64) + (2 * count(uint64))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (2 * count(uint64)) + sum(uint64)
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT sum(uint64) - (2 * count(uint64))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (2 * count(uint64)) - sum(uint64)
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
--
|
||||
21.5
|
||||
21.5
|
||||
21.5
|
||||
21.5
|
||||
26.5
|
||||
26.5
|
||||
6.5
|
||||
-6.5
|
||||
SELECT sum(float64) + (2 * count(float64))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (2 * count(float64)) + sum(float64)
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT sum(float64) - (2 * count(float64))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (2 * count(float64)) - sum(float64)
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT sum(float64) + (2 * count(float64))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (2 * count(float64)) + sum(float64)
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT sum(float64) - (2 * count(float64))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (2 * count(float64)) - sum(float64)
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
--
|
||||
21.65
|
||||
21.65
|
||||
21.65
|
||||
21.65
|
||||
26.65
|
||||
26.65
|
||||
6.65
|
||||
-6.65
|
||||
SELECT sum(decimal32) + (2 * count(decimal32))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (2 * count(decimal32)) + sum(decimal32)
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT sum(decimal32) - (2 * count(decimal32))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (2 * count(decimal32)) - sum(decimal32)
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT sum(decimal32) + (2 * count(decimal32))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (2 * count(decimal32)) + sum(decimal32)
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT sum(decimal32) - (2 * count(decimal32))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (2 * count(decimal32)) - sum(decimal32)
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
--
|
||||
40
|
||||
0
|
||||
0
|
||||
0
|
||||
55
|
||||
-5
|
||||
5
|
||||
5
|
||||
-5
|
||||
SELECT (sum(uint64) + (2 * count(uint64))) + (sum(uint64) + (3 * count(uint64)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (sum(uint64) + (2 * count(uint64))) - (sum(uint64) + (3 * count(uint64)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (sum(uint64) - (2 * count(uint64))) + (sum(uint64) - (3 * count(uint64)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (sum(uint64) - (2 * count(uint64))) - (sum(uint64) - (3 * count(uint64)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT ((2 * count(uint64)) - sum(uint64)) - ((3 * count(uint64)) - sum(uint64))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (sum(uint64) + (2 * count(uint64))) + (sum(uint64) + (3 * count(uint64)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (sum(uint64) + (2 * count(uint64))) - (sum(uint64) + (3 * count(uint64)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (sum(uint64) - (2 * count(uint64))) + (sum(uint64) - (3 * count(uint64)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (sum(uint64) - (2 * count(uint64))) - (sum(uint64) - (3 * count(uint64)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT ((2 * count(uint64)) - sum(uint64)) + ((3 * count(uint64)) - sum(uint64))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
--
|
||||
43
|
||||
0
|
||||
43
|
||||
0
|
||||
0
|
||||
58
|
||||
-5
|
||||
8
|
||||
5
|
||||
-8
|
||||
SELECT (sum(float64) + (2 * count(float64))) + (sum(float64) + (3 * count(float64)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (sum(float64) + (2 * count(float64))) - (sum(float64) + (3 * count(float64)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (sum(float64) - (2 * count(float64))) + (sum(float64) - (3 * count(float64)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (sum(float64) - (2 * count(float64))) - (sum(float64) - (3 * count(float64)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT ((2 * count(float64)) - sum(float64)) - ((3 * count(float64)) - sum(float64))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (sum(float64) + (2 * count(float64))) + (sum(float64) + (3 * count(float64)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (sum(float64) + (2 * count(float64))) - (sum(float64) + (3 * count(float64)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (sum(float64) - (2 * count(float64))) + (sum(float64) - (3 * count(float64)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (sum(float64) - (2 * count(float64))) - (sum(float64) - (3 * count(float64)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT ((2 * count(float64)) - sum(float64)) + ((3 * count(float64)) - sum(float64))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
--
|
||||
43.3
|
||||
0
|
||||
43.3
|
||||
0
|
||||
0
|
||||
58.3
|
||||
-5
|
||||
8.3
|
||||
5
|
||||
-8.3
|
||||
SELECT (sum(decimal32) + (2 * count(decimal32))) + (sum(decimal32) + (3 * count(decimal32)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (sum(decimal32) + (2 * count(decimal32))) - (sum(decimal32) + (3 * count(decimal32)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (sum(decimal32) - (2 * count(decimal32))) + (sum(decimal32) - (3 * count(decimal32)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (sum(decimal32) - (2 * count(decimal32))) - (sum(decimal32) - (3 * count(decimal32)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT ((2 * count(decimal32)) - sum(decimal32)) - ((3 * count(decimal32)) - sum(decimal32))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (sum(decimal32) + (2 * count(decimal32))) + (sum(decimal32) + (3 * count(decimal32)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (sum(decimal32) + (2 * count(decimal32))) - (sum(decimal32) + (3 * count(decimal32)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (sum(decimal32) - (2 * count(decimal32))) + (sum(decimal32) - (3 * count(decimal32)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT (sum(decimal32) - (2 * count(decimal32))) - (sum(decimal32) - (3 * count(decimal32)))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
||||
SELECT ((2 * count(decimal32)) - sum(decimal32)) + ((3 * count(decimal32)) - sum(decimal32))
|
||||
FROM test_table
|
||||
SETTINGS allow_experimental_analyzer = 1
|
@ -0,0 +1,220 @@
|
||||
Select sum(number + 1) from numbers(10) SETTINGS allow_experimental_analyzer=1;
|
||||
Select sum(1 + number) from numbers(10) SETTINGS allow_experimental_analyzer=1;
|
||||
Select sum(number - 1) from numbers(10) SETTINGS allow_experimental_analyzer=1;
|
||||
Select sum(1 - number) from numbers(10) SETTINGS allow_experimental_analyzer=1;
|
||||
EXPLAIN SYNTAX (Select sum(number + 1) from numbers(10) SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (Select sum(1 + number) from numbers(10) SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (Select sum(number - 1) from numbers(10) SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (Select sum(1 - number) from numbers(10) SETTINGS allow_experimental_analyzer=1);
|
||||
SELECT '--';
|
||||
|
||||
WITH 1::Nullable(UInt64) as my_literal Select sum(number + my_literal) from numbers(0) SETTINGS allow_experimental_analyzer=1;
|
||||
WITH 1::Nullable(UInt64) as my_literal Select sum(number) + my_literal * count() from numbers(0) SETTINGS allow_experimental_analyzer=1;
|
||||
EXPLAIN SYNTAX (WITH 1::Nullable(UInt64) as my_literal Select sum(number + my_literal) from numbers(0) SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (WITH 1::Nullable(UInt64) as my_literal Select sum(number) + my_literal * count() from numbers(0) SETTINGS allow_experimental_analyzer=1);
|
||||
SELECT '--';
|
||||
|
||||
DROP TABLE IF EXISTS test_table;
|
||||
|
||||
CREATE TABLE test_table
|
||||
(
|
||||
uint64 UInt64,
|
||||
float64 Float64,
|
||||
decimal32 Decimal32(5),
|
||||
) ENGINE=MergeTree ORDER BY uint64;
|
||||
|
||||
INSERT INTO test_table VALUES (1, 1.1, 1.11);
|
||||
INSERT INTO test_table VALUES (2, 2.2, 2.22);
|
||||
INSERT INTO test_table VALUES (3, 3.3, 3.33);
|
||||
INSERT INTO test_table VALUES (4, 4.4, 4.44);
|
||||
INSERT INTO test_table VALUES (5, 5.5, 5.55);
|
||||
|
||||
SELECT sum(uint64 + 1 AS i) from test_table where i > 0 SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(uint64 + 1) AS j from test_table having j > 0 SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(uint64 + 1 AS i) j from test_table where i > 0 having j > 0 SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum((uint64 AS m) + (1 AS n)) j from test_table where m > 0 and n > 0 having j > 0 SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(((uint64 AS m) + (1 AS n)) AS i) j from test_table where m > 0 and n > 0 and i > 0 having j > 0 SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT '--';
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 + 1 AS i) from test_table where i > 0 SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 + 1) AS j from test_table having j > 0 SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 + 1 AS i) j from test_table where i > 0 having j > 0 SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum((uint64 AS m) + (1 AS n)) j from test_table where m > 0 and n > 0 having j > 0 SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(((uint64 AS m) + (1 AS n)) AS i) j from test_table where m > 0 and n > 0 and i > 0 having j > 0 SETTINGS allow_experimental_analyzer=1);
|
||||
SELECT '--';
|
||||
|
||||
SELECT sum(1 + uint64 AS i) from test_table where i > 0 SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(1 + uint64) AS j from test_table having j > 0 SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(1 + uint64 AS i) j from test_table where i > 0 having j > 0 SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum((1 AS m) + (uint64 AS n)) j from test_table where m > 0 and n > 0 having j > 0 SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(((1 AS m) + (uint64 AS n)) AS i) j from test_table where m > 0 and n > 0 and i > 0 having j > 0 SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT '--';
|
||||
EXPLAIN SYNTAX (SELECT sum(1 + uint64 AS i) from test_table where i > 0 SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(1 + uint64) AS j from test_table having j > 0 SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(1 + uint64 AS i) j from test_table where i > 0 having j > 0 SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum((1 AS m) + (uint64 AS n)) j from test_table where m > 0 and n > 0 having j > 0 SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(((1 AS m) + (uint64 AS n)) AS i) j from test_table where m > 0 and n > 0 and i > 0 having j > 0 SETTINGS allow_experimental_analyzer=1);
|
||||
SELECT '--';
|
||||
|
||||
SELECT sum(uint64 - 1 AS i) from test_table where i > 0 SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(uint64 - 1) AS j from test_table having j > 0 SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(uint64 - 1 AS i) j from test_table where i > 0 having j > 0 SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum((uint64 AS m) - (1 AS n)) j from test_table where m > 0 and n > 0 having j > 0 SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(((uint64 AS m) - (1 AS n)) AS i) j from test_table where m > 0 and n > 0 and i > 0 having j > 0 SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT '--';
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 - 1 AS i) from test_table where i > 0 SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 - 1) AS j from test_table having j > 0 SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 - 1 AS i) j from test_table where i > 0 having j > 0 SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum((uint64 AS m) - (1 AS n)) j from test_table where m > 0 and n > 0 having j > 0 SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(((uint64 AS m) - (1 AS n)) AS i) j from test_table where m > 0 and n > 0 and i > 0 having j > 0 SETTINGS allow_experimental_analyzer=1);
|
||||
SELECT '--';
|
||||
|
||||
SELECT sum(1 - uint64 AS i) from test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(1 - uint64) AS j from test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(1 - uint64 AS i) j from test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum((1 AS m) - (uint64 AS n)) j from test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(((1 AS m) - (uint64 AS n)) AS i) j from test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT '--';
|
||||
EXPLAIN SYNTAX (SELECT sum(1 - uint64 AS i) from test_table where i > 0 SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(1 - uint64) AS j from test_table having j < 0 SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(1 - uint64 AS i) j from test_table where i > 0 having j < 0 SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum((1 AS m) - (uint64 AS n)) j from test_table where m > 0 and n > 0 having j < 0 SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(((1 AS m) - (uint64 AS n)) AS i) j from test_table where m > 0 and n > 0 and i < 0 having j < 0 SETTINGS allow_experimental_analyzer=1);
|
||||
SELECT '--';
|
||||
|
||||
SELECT sum(uint64 + 2.11) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(2.11 + uint64) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(uint64 - 2.11) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(2.11 - uint64) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(uint64) + 2.11 * count(uint64) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT 2.11 * count(uint64) + sum(uint64) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(uint64) - 2.11 * count(uint64) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT 2.11 * count(uint64) - sum(uint64) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 + 2.11) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(2.11 + uint64) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 - 2.11) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(2.11 - uint64) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64) + 2.11 * count(uint64) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT 2.11 * count(uint64) + sum(uint64) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64) - 2.11 * count(uint64) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT 2.11 * count(uint64) - sum(uint64) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
SELECT '--';
|
||||
|
||||
SELECT sum(uint64 + 2) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(2 + uint64) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(uint64 - 2) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(2 - uint64) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(uint64) + 2 * count(uint64) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT 2 * count(uint64) + sum(uint64) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(uint64) - 2 * count(uint64) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT 2 * count(uint64) - sum(uint64) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 + 2) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(2 + uint64) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 - 2) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(2 - uint64) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64) + 2 * count(uint64) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT 2 * count(uint64) + sum(uint64) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64) - 2 * count(uint64) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT 2 * count(uint64) - sum(uint64) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
SELECT '--';
|
||||
|
||||
SELECT sum(float64 + 2) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(2 + float64) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(float64 - 2) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(2 - float64) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(float64) + 2 * count(float64) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT 2 * count(float64) + sum(float64) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(float64) - 2 * count(float64) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT 2 * count(float64) - sum(float64) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
EXPLAIN SYNTAX (SELECT sum(float64 + 2) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(2 + float64) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(float64 - 2) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(2 - float64) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(float64) + 2 * count(float64) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT 2 * count(float64) + sum(float64) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(float64) - 2 * count(float64) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT 2 * count(float64) - sum(float64) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
SELECT '--';
|
||||
|
||||
SELECT sum(decimal32 + 2) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(2 + decimal32) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(decimal32 - 2) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(2 - decimal32) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(decimal32) + 2 * count(decimal32) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT 2 * count(decimal32) + sum(decimal32) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(decimal32) - 2 * count(decimal32) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT 2 * count(decimal32) - sum(decimal32) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
EXPLAIN SYNTAX (SELECT sum(decimal32 + 2) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(2 + decimal32) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(decimal32 - 2) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(2 - decimal32) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(decimal32) + 2 * count(decimal32) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT 2 * count(decimal32) + sum(decimal32) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(decimal32) - 2 * count(decimal32) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT 2 * count(decimal32) - sum(decimal32) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
SELECT '--';
|
||||
|
||||
SELECT sum(uint64 + 2) + sum(uint64 + 3) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(uint64 + 2) - sum(uint64 + 3) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(uint64 - 2) - sum(uint64 - 3) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(2 - uint64) - sum(3 - uint64) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT (sum(uint64) + 2 * count(uint64)) + (sum(uint64) + 3 * count(uint64)) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT (sum(uint64) + 2 * count(uint64)) - (sum(uint64) + 3 * count(uint64)) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT (sum(uint64) - 2 * count(uint64)) + (sum(uint64) - 3 * count(uint64)) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT (sum(uint64) - 2 * count(uint64)) - (sum(uint64) - 3 * count(uint64)) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT (2 * count(uint64) - sum(uint64)) + (3 * count(uint64) - sum(uint64)) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 + 2) + sum(uint64 + 3) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 + 2) - sum(uint64 + 3) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 - 2) + sum(uint64 - 3) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(uint64 - 2) - sum(uint64 - 3) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(2 - uint64) - sum(3 - uint64) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT (sum(uint64) + 2 * count(uint64)) + (sum(uint64) + 3 * count(uint64)) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT (sum(uint64) + 2 * count(uint64)) - (sum(uint64) + 3 * count(uint64)) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT (sum(uint64) - 2 * count(uint64)) + (sum(uint64) - 3 * count(uint64)) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT (sum(uint64) - 2 * count(uint64)) - (sum(uint64) - 3 * count(uint64)) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT (2 * count(uint64) - sum(uint64)) + (3 * count(uint64) - sum(uint64)) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
SELECT '--';
|
||||
|
||||
SELECT sum(float64 + 2) + sum(float64 + 3) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(float64 + 2) - sum(float64 + 3) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(float64 - 2) + sum(float64 - 3) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(float64 - 2) - sum(float64 - 3) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(2 - float64) - sum(3 - float64) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT (sum(float64) + 2 * count(float64)) + (sum(float64) + 3 * count(float64)) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT (sum(float64) + 2 * count(float64)) - (sum(float64) + 3 * count(float64)) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT (sum(float64) - 2 * count(float64)) + (sum(float64) - 3 * count(float64)) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT (sum(float64) - 2 * count(float64)) - (sum(float64) - 3 * count(float64)) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT (2 * count(float64) - sum(float64)) + (3 * count(float64) - sum(float64)) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
EXPLAIN SYNTAX (SELECT sum(float64 + 2) + sum(float64 + 3) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(float64 + 2) - sum(float64 + 3) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(float64 - 2) + sum(float64 - 3) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(float64 - 2) - sum(float64 - 3) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(2 - float64) - sum(3 - float64) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT (sum(float64) + 2 * count(float64)) + (sum(float64) + 3 * count(float64)) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT (sum(float64) + 2 * count(float64)) - (sum(float64) + 3 * count(float64)) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT (sum(float64) - 2 * count(float64)) + (sum(float64) - 3 * count(float64)) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT (sum(float64) - 2 * count(float64)) - (sum(float64) - 3 * count(float64)) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT (2 * count(float64) - sum(float64)) + (3 * count(float64) - sum(float64)) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
SELECT '--';
|
||||
|
||||
SELECT sum(decimal32 + 2) + sum(decimal32 + 3) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(decimal32 + 2) - sum(decimal32 + 3) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(decimal32 - 2) + sum(decimal32 - 3) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(decimal32 - 2) - sum(decimal32 - 3) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT sum(2 - decimal32) - sum(3 - decimal32) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT (sum(decimal32) + 2 * count(decimal32)) + (sum(decimal32) + 3 * count(decimal32)) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT (sum(decimal32) + 2 * count(decimal32)) - (sum(decimal32) + 3 * count(decimal32)) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT (sum(decimal32) - 2 * count(decimal32)) + (sum(decimal32) - 3 * count(decimal32)) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT (sum(decimal32) - 2 * count(decimal32)) - (sum(decimal32) - 3 * count(decimal32)) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
SELECT (2 * count(decimal32) - sum(decimal32)) + (3 * count(decimal32) - sum(decimal32)) From test_table SETTINGS allow_experimental_analyzer=1;
|
||||
EXPLAIN SYNTAX (SELECT sum(decimal32 + 2) + sum(decimal32 + 3) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(decimal32 + 2) - sum(decimal32 + 3) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(decimal32 - 2) + sum(decimal32 - 3) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(decimal32 - 2) - sum(decimal32 - 3) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT sum(2 - decimal32) - sum(3 - decimal32) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT (sum(decimal32) + 2 * count(decimal32)) + (sum(decimal32) + 3 * count(decimal32)) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT (sum(decimal32) + 2 * count(decimal32)) - (sum(decimal32) + 3 * count(decimal32)) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT (sum(decimal32) - 2 * count(decimal32)) + (sum(decimal32) - 3 * count(decimal32)) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT (sum(decimal32) - 2 * count(decimal32)) - (sum(decimal32) - 3 * count(decimal32)) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
EXPLAIN SYNTAX (SELECT (2 * count(decimal32) - sum(decimal32)) + (3 * count(decimal32) - sum(decimal32)) From test_table SETTINGS allow_experimental_analyzer=1);
|
||||
|
||||
DROP TABLE IF EXISTS test_table;
|
Loading…
Reference in New Issue
Block a user