未验证 提交 b99b9d44 编写于 作者: V Vitaly Baranov 提交者: GitHub

Merge pull request #19781 from ClickHouse/backport/20.12/19763

Backport #19763 to 20.12: Fix crash when nested column name was used in `WHERE` or `PREWHERE`
......@@ -658,7 +658,12 @@ ActionsDAGPtr SelectQueryExpressionAnalyzer::appendPrewhere(
step.required_output.push_back(prewhere_column_name);
step.can_remove_required_output.push_back(true);
auto filter_type = (*step.actions()->getIndex().find(prewhere_column_name))->result_type;
const auto & index = step.actions()->getIndex();
auto it = index.find(prewhere_column_name);
if (it == index.end())
throw Exception(ErrorCodes::UNKNOWN_IDENTIFIER, "Unknown identifier: '{}'", prewhere_column_name);
auto filter_type = (*it)->result_type;
if (!filter_type->canBeUsedInBooleanContext())
throw Exception("Invalid type for filter in PREWHERE: " + filter_type->getName(),
ErrorCodes::ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER);
......@@ -758,7 +763,12 @@ bool SelectQueryExpressionAnalyzer::appendWhere(ExpressionActionsChain & chain,
step.required_output.push_back(where_column_name);
step.can_remove_required_output = {true};
auto filter_type = (*step.actions()->getIndex().find(where_column_name))->result_type;
const auto & index = step.actions()->getIndex();
auto it = index.find(where_column_name);
if (it == index.end())
throw Exception(ErrorCodes::UNKNOWN_IDENTIFIER, "Unknown identifier: '{}'", where_column_name);
auto filter_type = (*it)->result_type;
if (!filter_type->canBeUsedInBooleanContext())
throw Exception("Invalid type for filter in WHERE: " + filter_type->getName(),
ErrorCodes::ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER);
......
drop table if exists tab;
create table tab (x UInt64, `arr.a` Array(UInt64), `arr.b` Array(UInt64)) engine = MergeTree order by x;
select x from tab array join arr prewhere x != 0 where arr; -- { serverError 47; }
select x from tab array join arr prewhere arr where x != 0; -- { serverError 47; }
drop table if exists tab;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册