mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 13:02:00 +00:00
CompileExpressions comparison function constant case fix
This commit is contained in:
parent
520d992df2
commit
26be39f419
@ -328,6 +328,13 @@ static bool checkIfFunctionIsComparisonEdgeCase(const ActionsDAG::Node & node, c
|
||||
NameGreaterOrEquals::name
|
||||
};
|
||||
|
||||
/** Comparision operator is special case for ActionDAG compilation
|
||||
* Its result can be constant and we can understand that only during Function execute call.
|
||||
* It can be a problem if two DAGs with compare function are analyzed, but in first DAG comparison
|
||||
* function is compiled, in second DAG it is not compiled.
|
||||
* There will be error because of block headers mismatch.
|
||||
*/
|
||||
|
||||
auto it = comparison_functions.find(impl.getName());
|
||||
if (it == comparison_functions.end())
|
||||
return false;
|
||||
@ -335,6 +342,12 @@ static bool checkIfFunctionIsComparisonEdgeCase(const ActionsDAG::Node & node, c
|
||||
const auto * lhs_node = node.children[0];
|
||||
const auto * rhs_node = node.children[1];
|
||||
|
||||
while (lhs_node->type == ActionsDAG::ActionType::ALIAS)
|
||||
lhs_node = lhs_node->children[0];
|
||||
|
||||
while (rhs_node->type == ActionsDAG::ActionType::ALIAS)
|
||||
rhs_node = rhs_node->children[0];
|
||||
|
||||
return lhs_node == rhs_node && !isTuple(lhs_node->result_type);
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,11 @@
|
||||
ComparisionOperator column with same column
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
ComparisionOperator column with alias on same column
|
||||
1
|
||||
1
|
||||
1
|
||||
|
@ -1,6 +1,8 @@
|
||||
SET compile_expressions = 1;
|
||||
SET min_count_to_compile_expression = 0;
|
||||
|
||||
SELECT 'ComparisionOperator column with same column';
|
||||
|
||||
DROP TABLE IF EXISTS test_table;
|
||||
CREATE TABLE test_table (a UInt64) ENGINE = MergeTree() ORDER BY tuple();
|
||||
INSERT INTO test_table VALUES (1);
|
||||
@ -13,3 +15,22 @@ SELECT test_table.a FROM test_table ORDER BY (test_table.a <= test_table.a) + 1;
|
||||
|
||||
SELECT test_table.a FROM test_table ORDER BY (test_table.a == test_table.a) + 1;
|
||||
SELECT test_table.a FROM test_table ORDER BY (test_table.a != test_table.a) + 1;
|
||||
|
||||
DROP TABLE test_table;
|
||||
|
||||
SELECT 'ComparisionOperator column with alias on same column';
|
||||
|
||||
DROP TABLE IF EXISTS test_table;
|
||||
CREATE TABLE test_table (a UInt64, b ALIAS a, c ALIAS b) ENGINE = MergeTree() ORDER BY tuple();
|
||||
INSERT INTO test_table VALUES (1);
|
||||
|
||||
SELECT test_table.a FROM test_table ORDER BY (test_table.a > test_table.b) + 1 AND (test_table.a > test_table.c) + 1;
|
||||
SELECT test_table.a FROM test_table ORDER BY (test_table.a >= test_table.b) + 1 AND (test_table.a >= test_table.c) + 1;
|
||||
|
||||
SELECT test_table.a FROM test_table ORDER BY (test_table.a < test_table.b) + 1 AND (test_table.a < test_table.c) + 1;
|
||||
SELECT test_table.a FROM test_table ORDER BY (test_table.a <= test_table.b) + 1 AND (test_table.a <= test_table.c) + 1;
|
||||
|
||||
SELECT test_table.a FROM test_table ORDER BY (test_table.a == test_table.b) + 1 AND (test_table.a == test_table.c) + 1;
|
||||
SELECT test_table.a FROM test_table ORDER BY (test_table.a != test_table.b) + 1 AND (test_table.a != test_table.c) + 1;
|
||||
|
||||
DROP TABLE test_table;
|
||||
|
Loading…
Reference in New Issue
Block a user