mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
Merge pull request #70464 from Algunenano/fix_analyzer
Fix crash in WHERE with lambda functions
This commit is contained in:
commit
46824d0434
@ -19,6 +19,8 @@ namespace ErrorCodes
|
|||||||
extern const int BAD_ARGUMENTS;
|
extern const int BAD_ARGUMENTS;
|
||||||
extern const int ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER;
|
extern const int ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER;
|
||||||
extern const int ILLEGAL_PREWHERE;
|
extern const int ILLEGAL_PREWHERE;
|
||||||
|
extern const int UNSUPPORTED_METHOD;
|
||||||
|
extern const int UNEXPECTED_EXPRESSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@ -26,11 +28,24 @@ namespace
|
|||||||
|
|
||||||
void validateFilter(const QueryTreeNodePtr & filter_node, std::string_view exception_place_message, const QueryTreeNodePtr & query_node)
|
void validateFilter(const QueryTreeNodePtr & filter_node, std::string_view exception_place_message, const QueryTreeNodePtr & query_node)
|
||||||
{
|
{
|
||||||
if (filter_node->getNodeType() == QueryTreeNodeType::LIST)
|
DataTypePtr filter_node_result_type;
|
||||||
throw Exception(ErrorCodes::BAD_ARGUMENTS,
|
try
|
||||||
"Unsupported expression '{}' in filter", filter_node->formatASTForErrorMessage());
|
{
|
||||||
|
filter_node_result_type = filter_node->getResultType();
|
||||||
|
}
|
||||||
|
catch (const DB::Exception &e)
|
||||||
|
{
|
||||||
|
if (e.code() != ErrorCodes::UNSUPPORTED_METHOD)
|
||||||
|
e.rethrow();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!filter_node_result_type)
|
||||||
|
throw Exception(ErrorCodes::UNEXPECTED_EXPRESSION,
|
||||||
|
"Unexpected expression '{}' in filter in {}. In query {}",
|
||||||
|
filter_node->formatASTForErrorMessage(),
|
||||||
|
exception_place_message,
|
||||||
|
query_node->formatASTForErrorMessage());
|
||||||
|
|
||||||
auto filter_node_result_type = filter_node->getResultType();
|
|
||||||
if (!filter_node_result_type->canBeUsedInBooleanContext())
|
if (!filter_node_result_type->canBeUsedInBooleanContext())
|
||||||
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER,
|
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER,
|
||||||
"Invalid type for filter in {}: {}. In query {}",
|
"Invalid type for filter in {}: {}. In query {}",
|
||||||
|
@ -39,7 +39,7 @@ SELECT * GROUP BY *;
|
|||||||
-- not ok as every component of ORDER BY may contain ASC/DESC and COLLATE; though can be supported in some sense
|
-- not ok as every component of ORDER BY may contain ASC/DESC and COLLATE; though can be supported in some sense
|
||||||
-- but it works
|
-- but it works
|
||||||
SELECT * ORDER BY *;
|
SELECT * ORDER BY *;
|
||||||
SELECT * WHERE *; -- { serverError BAD_ARGUMENTS }
|
SELECT * WHERE *; -- { serverError UNEXPECTED_EXPRESSION }
|
||||||
|
|
||||||
SELECT '---';
|
SELECT '---';
|
||||||
|
|
||||||
|
1
tests/queries/0_stateless/03248_invalid_where.sql
Normal file
1
tests/queries/0_stateless/03248_invalid_where.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
WITH x -> toString(x) AS lambda_1 SELECT arrayMap(lambda_1 AS lambda_2, [1, 2, 3]), arrayMap(lambda_2, ['1', '2', '3']) WHERE lambda_2; -- { serverError UNEXPECTED_EXPRESSION }
|
Loading…
Reference in New Issue
Block a user