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

Function validateKeyTypes

src/Dictionaries/IPAddressDictionary.cpp:142–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142static void validateKeyTypes(const DataTypes & key_types)
143{
144 if (key_types.empty() || key_types.size() > 2)
145 throw Exception(ErrorCodes::TYPE_MISMATCH, "Expected a single IP address or IP with mask");
146
147 TypeIndex type_id = key_types[0]->getTypeId();
148 const auto * key_string = typeid_cast<const DataTypeFixedString *>(key_types[0].get());
149
150 if (type_id != TypeIndex::IPv4 && type_id != TypeIndex::UInt32 && type_id != TypeIndex::IPv6 && !(key_string && key_string->getN() == IPV6_BINARY_LENGTH))
151 throw Exception(ErrorCodes::TYPE_MISMATCH,
152 "Key does not match, expected either IPv4 (or UInt32) or IPv6 (or FixedString(16))");
153
154 if (key_types.size() > 1)
155 {
156 const auto * mask_col_type = typeid_cast<const DataTypeUInt8 *>(key_types[1].get());
157 if (mask_col_type == nullptr)
158 throw Exception(ErrorCodes::TYPE_MISMATCH, "Mask do not match, expected UInt8");
159 }
160}
161
162template <typename T, typename Comp>
163size_t sortAndUnique(VectorWithMemoryTracking<T> & vec, Comp comp)

Callers 2

getColumnMethod · 0.85
hasKeysMethod · 0.85

Calls 6

ExceptionClass · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
getTypeIdMethod · 0.45
getMethod · 0.45
getNMethod · 0.45

Tested by

no test coverage detected