Analyzer function IN crash fix

This commit is contained in:
Maksim Kita 2023-01-09 15:35:14 +01:00
parent 119501f1d9
commit f96cdc7e47
3 changed files with 20 additions and 7 deletions

View File

@ -4155,10 +4155,7 @@ ProjectionNames QueryAnalyzer::resolveFunction(QueryTreeNodePtr & node, Identifi
argument_column.type = std::make_shared<DataTypeFunction>(DataTypes(lambda_arguments_size, nullptr), nullptr);
function_lambda_arguments_indexes.push_back(function_argument_index);
}
else if (is_special_function_in &&
(function_argument->getNodeType() == QueryTreeNodeType::TABLE ||
function_argument->getNodeType() == QueryTreeNodeType::QUERY ||
function_argument->getNodeType() == QueryTreeNodeType::UNION))
else if (is_special_function_in && function_argument_index == 1)
{
argument_column.type = std::make_shared<DataTypeSet>();
}
@ -4534,16 +4531,15 @@ ProjectionNames QueryAnalyzer::resolveFunction(QueryTreeNodePtr & node, Identifi
auto column_set = ColumnSet::create(1, std::move(set));
argument_columns[1].column = ColumnConst::create(std::move(column_set), 1);
}
argument_columns[1].type = std::make_shared<DataTypeSet>();
}
std::shared_ptr<ConstantValue> constant_value;
DataTypePtr result_type;
try
{
auto function_base = function->build(argument_columns);
result_type = function_base->getResultType();
/** If function is suitable for constant folding try to convert it to constant.
* Example: SELECT plus(1, 1);
@ -4551,6 +4547,7 @@ ProjectionNames QueryAnalyzer::resolveFunction(QueryTreeNodePtr & node, Identifi
*/
if (function_base->isSuitableForConstantFolding())
{
auto result_type = function_base->getResultType();
auto executable_function = function_base->prepare(argument_columns);
ColumnPtr column;

View File

@ -0,0 +1,14 @@
SET allow_experimental_analyzer = 1;
DROP TABLE IF EXISTS test_table;
CREATE TABLE test_table
(
id UInt8,
value Nullable(Decimal(38, 2))
) ENGINE = MergeTree ORDER BY id;
INSERT INTO test_table VALUES (1, '22.5'), (2, Null);
SELECT id IN toDecimal64(257, NULL) FROM test_table;
DROP TABLE test_table;