| 36 | { |
| 37 | |
| 38 | void validateFilter(const QueryTreeNodePtr & filter_node, std::string_view exception_place_message, const QueryTreeNodePtr & query_node) |
| 39 | { |
| 40 | DataTypePtr filter_node_result_type; |
| 41 | try |
| 42 | { |
| 43 | filter_node_result_type = filter_node->getResultType(); |
| 44 | } |
| 45 | catch (const DB::Exception &e) |
| 46 | { |
| 47 | if (e.code() != ErrorCodes::UNSUPPORTED_METHOD) |
| 48 | e.rethrow(); |
| 49 | } |
| 50 | |
| 51 | if (!filter_node_result_type) |
| 52 | throw Exception(ErrorCodes::UNEXPECTED_EXPRESSION, |
| 53 | "Unexpected expression '{}' in filter in {}. In query {}", |
| 54 | filter_node->formatASTForErrorMessage(), |
| 55 | exception_place_message, |
| 56 | query_node->formatASTForErrorMessage()); |
| 57 | |
| 58 | if (!filter_node_result_type->canBeUsedInBooleanContext()) |
| 59 | throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER, |
| 60 | "Invalid type for filter in {}: {}. In query {}", |
| 61 | exception_place_message, |
| 62 | filter_node_result_type->getName(), |
| 63 | query_node->formatASTForErrorMessage()); |
| 64 | } |
| 65 | |
| 66 | } |
| 67 |
no test coverage detected