[fix](Function) fix to_bitmap to return always not nullable (#9859)
This commit is contained in:
@ -39,24 +39,39 @@ struct BitmapEmpty {
|
||||
|
||||
struct ToBitmap {
|
||||
static constexpr auto name = "to_bitmap";
|
||||
using ReturnType = DataTypeBitMap;
|
||||
|
||||
static void vector(const ColumnString::Chars& data, const ColumnString::Offsets& offsets,
|
||||
MutableColumnPtr& col_res) {
|
||||
execute<false>(data, offsets, nullptr, col_res);
|
||||
}
|
||||
|
||||
static void vector_nullable(const ColumnString::Chars& data,
|
||||
const ColumnString::Offsets& offsets, const NullMap& nullmap,
|
||||
MutableColumnPtr& col_res) {
|
||||
execute<true>(data, offsets, &nullmap, col_res);
|
||||
}
|
||||
template <bool arg_is_nullable>
|
||||
static void execute(const ColumnString::Chars& data, const ColumnString::Offsets& offsets,
|
||||
const NullMap* nullmap, MutableColumnPtr& col_res) {
|
||||
auto* res_column = reinterpret_cast<ColumnBitmap*>(col_res.get());
|
||||
auto& res_data = res_column->get_data();
|
||||
size_t size = offsets.size();
|
||||
|
||||
static Status vector(const ColumnString::Chars& data, const ColumnString::Offsets& offsets,
|
||||
std::vector<BitmapValue>& res, NullMap& null_map) {
|
||||
auto size = offsets.size();
|
||||
res.reserve(size);
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
res.emplace_back();
|
||||
|
||||
const char* raw_str = reinterpret_cast<const char*>(&data[offsets[i - 1]]);
|
||||
size_t str_size = offsets[i] - offsets[i - 1] - 1;
|
||||
StringParser::ParseResult parse_result = StringParser::PARSE_SUCCESS;
|
||||
uint64_t int_value = StringParser::string_to_unsigned_int<uint64_t>(raw_str, str_size,
|
||||
&parse_result);
|
||||
if (LIKELY(parse_result == StringParser::PARSE_SUCCESS)) {
|
||||
res.back().add(int_value);
|
||||
if (arg_is_nullable && ((*nullmap)[i])) {
|
||||
continue;
|
||||
} else {
|
||||
const char* raw_str = reinterpret_cast<const char*>(&data[offsets[i - 1]]);
|
||||
size_t str_size = offsets[i] - offsets[i - 1] - 1;
|
||||
StringParser::ParseResult parse_result = StringParser::PARSE_SUCCESS;
|
||||
uint64_t int_value = StringParser::string_to_unsigned_int<uint64_t>(
|
||||
raw_str, str_size, &parse_result);
|
||||
if (LIKELY(parse_result == StringParser::PARSE_SUCCESS)) {
|
||||
res_data[i].add(int_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
};
|
||||
|
||||
@ -494,7 +509,7 @@ public:
|
||||
};
|
||||
|
||||
using FunctionBitmapEmpty = FunctionConst<BitmapEmpty, false>;
|
||||
using FunctionToBitmap = FunctionBitmapAlwaysNull<ToBitmap>;
|
||||
using FunctionToBitmap = FunctionAlwaysNotNullable<ToBitmap>;
|
||||
using FunctionBitmapFromString = FunctionBitmapAlwaysNull<BitmapFromString>;
|
||||
using FunctionBitmapHash = FunctionAlwaysNotNullable<BitmapHash>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user