mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Fix tryInsert for ColumnUInt8 and Bool
This commit is contained in:
parent
567a550149
commit
f0b955888b
@ -460,6 +460,28 @@ Float32 ColumnVector<T>::getFloat32(size_t n [[maybe_unused]]) const
|
||||
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Cannot get the value of {} as Float32", TypeName<T>);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool ColumnVector<T>::tryInsert(const DB::Field & x)
|
||||
{
|
||||
NearestFieldType<T> value;
|
||||
if (!x.tryGet<NearestFieldType<T>>(value))
|
||||
{
|
||||
if constexpr (std::is_same_v<T, UInt8>)
|
||||
{
|
||||
/// It's also possible to insert boolean values into UInt8 column.
|
||||
bool boolean_value;
|
||||
if (x.tryGet<bool>(boolean_value))
|
||||
{
|
||||
data.push_back(static_cast<T>(boolean_value));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
data.push_back(static_cast<T>(value));
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void ColumnVector<T>::insertRangeFrom(const IColumn & src, size_t start, size_t length)
|
||||
{
|
||||
|
@ -224,14 +224,8 @@ public:
|
||||
data.push_back(static_cast<T>(x.get<T>()));
|
||||
}
|
||||
|
||||
bool tryInsert(const DB::Field & x) override
|
||||
{
|
||||
NearestFieldType<T> value;
|
||||
if (!x.tryGet<NearestFieldType<T>>(value))
|
||||
return false;
|
||||
data.push_back(static_cast<T>(value));
|
||||
return true;
|
||||
}
|
||||
bool tryInsert(const DB::Field & x) override;
|
||||
|
||||
void insertRangeFrom(const IColumn & src, size_t start, size_t length) override;
|
||||
|
||||
ColumnPtr filter(const IColumn::Filter & filt, ssize_t result_size_hint) const override;
|
||||
|
Loading…
Reference in New Issue
Block a user