MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / validateGroupByKeyType

Function validateGroupByKeyType

src/DataTypes/validateGroupByKeyType.cpp:13–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11}
12
13void 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}

Callers 6

resolveWindowMethod · 0.85
resolveGroupByNodeMethod · 0.85
appendGroupByMethod · 0.85

Calls 3

ExceptionClass · 0.50
checkFunction · 0.50
forEachChildMethod · 0.45

Tested by

no test coverage detected