| 11 | } |
| 12 | |
| 13 | void validateGroupByKeyType(const DataTypePtr & key_type, bool allow_suspicious_types) |
| 14 | { |
| 15 | if (allow_suspicious_types) |
| 16 | return; |
| 17 | |
| 18 | auto check = [](const IDataType & type) |
| 19 | { |
| 20 | if (isDynamic(type) || isVariant(type)) |
| 21 | throw Exception( |
| 22 | ErrorCodes::ILLEGAL_COLUMN, |
| 23 | "Data types Variant/Dynamic are not allowed in GROUP BY keys, because it can lead to unexpected results. " |
| 24 | "Consider using a subcolumn with a specific data type instead (for example 'column.Int64' or 'json.some.path.:Int64' if " |
| 25 | "its a JSON path subcolumn) or casting this column to a specific data type. " |
| 26 | "Set setting allow_suspicious_types_in_group_by = 1 in order to allow it"); |
| 27 | }; |
| 28 | |
| 29 | check(*key_type); |
| 30 | key_type->forEachChild(check); |
| 31 | } |
| 32 | |
| 33 | } |
no test coverage detected