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

Method castToName

src/DataTypes/DataTypeEnum.cpp:165–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163
164template <typename Type>
165Field DataTypeEnum<Type>::castToName(const Field & value_or_name) const
166{
167 if (value_or_name.getType() == Field::Types::String)
168 {
169 this->getValue(value_or_name.safeGet<String>()); /// Check correctness
170 return value_or_name.safeGet<String>();
171 }
172 if (value_or_name.getType() == Field::Types::Int64)
173 {
174 Int64 value = value_or_name.safeGet<Int64>();
175 checkOverflow<Type>(value);
176 return std::string{this->getNameForValue(static_cast<Type>(value))};
177 }
178 throw Exception(ErrorCodes::BAD_TYPE_OF_FIELD, "DataTypeEnum: Unsupported type of field {}", value_or_name.getTypeName());
179}
180
181template <typename Type>
182Field DataTypeEnum<Type>::castToValue(const Field & value_or_name) const

Callers 1

writeProfileEventsMethod · 0.80

Calls 5

getNameForValueMethod · 0.80
ExceptionClass · 0.50
getTypeMethod · 0.45
getValueMethod · 0.45
getTypeNameMethod · 0.45

Tested by

no test coverage detected