Merge pull request #57123 from ClickHouse/vdimir/fix_logical_error_analyzer_or_optimize

Analyzer: Fix logical error in LogicalExpressionOptimizerVisitor
This commit is contained in:
vdimir 2023-11-23 11:24:28 +01:00 committed by GitHub
commit bbc577646f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 1 deletions

View File

@ -439,7 +439,7 @@ private:
}
/// otherwise add a stub 0 to make OR correct
or_operands.push_back(std::make_shared<ConstantNode>(static_cast<UInt8>(0)));
or_operands.push_back(std::make_shared<ConstantNode>(static_cast<UInt8>(0), function_node.getResultType()));
}
auto or_function_resolver = FunctionFactory::instance().get("or", getContext());

View File

@ -87,3 +87,4 @@ QUERY id: 0
LIST id: 6, nodes: 2
COLUMN id: 7, column_name: a, result_type: Int32, source_id: 3
CONSTANT id: 8, constant_value: UInt64_2, constant_value_type: UInt8
1

View File

@ -24,3 +24,5 @@ EXPLAIN QUERY TREE SELECT * FROM 02668_logical_optimizer WHERE a = 3 AND b = 'an
SELECT * FROM 02668_logical_optimizer WHERE a = 2 AND 2 = a;
EXPLAIN QUERY TREE SELECT * FROM 02668_logical_optimizer WHERE a = 2 AND 2 = a;
SELECT (k = 3) OR ( (k = 1) OR (k = 2) OR ( (NULL OR 1) = k ) ) FROM ( SELECT materialize(1) AS k );