Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions be/src/vec/columns/column_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ template <typename T>
void ColumnStr<T>::sanity_check() const {
#ifndef NDEBUG
sanity_check_simple();
auto count = offsets.size();
for (size_t i = 0; i < count; ++i) {
auto count = cast_set<int>(offsets.size());
for (int i = 0; i < count; ++i) {
if (offsets[i] < offsets[i - 1]) {
throw Exception(Status::InternalError("row count: {}, offsets[{}]: {}, offsets[{}]: {}",
count, i, offsets[i], i - 1, offsets[i - 1]));
Expand All @@ -53,10 +53,10 @@ void ColumnStr<T>::sanity_check() const {
template <typename T>
void ColumnStr<T>::sanity_check_simple() const {
#ifndef NDEBUG
auto count = offsets.size();
auto count = cast_set<int>(offsets.size());
if (chars.size() != offsets[count - 1]) {
throw Exception(Status::InternalError("row count: {}, chars.size(): {}, offset[{}]: ",
count, chars.size(), offsets[count - 1]));
throw Exception(Status::InternalError("row count: {}, chars.size(): {}, offset[{}]: {}",
count, chars.size(), count - 1, offsets[count - 1]));
}
if (offsets[-1] != 0) {
throw Exception(Status::InternalError("wrong offsets[-1]: {}", offsets[-1]));
Expand Down Expand Up @@ -639,6 +639,7 @@ template <typename T>
void ColumnStr<T>::compare_internal(size_t rhs_row_id, const IColumn& rhs, int nan_direction_hint,
int direction, std::vector<uint8>& cmp_res,
uint8* __restrict filter) const {
sanity_check_simple();
auto sz = offsets.size();
DCHECK(cmp_res.size() == sz);
const auto& cmp_base =
Expand Down
3 changes: 3 additions & 0 deletions be/src/vec/columns/column_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,13 @@ class ColumnStr final : public COWHelper<IColumn, ColumnStr<T>> {

Field operator[](size_t n) const override {
assert(n < size());
sanity_check_simple();
return Field(String(reinterpret_cast<const char*>(&chars[offset_at(n)]), size_at(n)));
}

void get(size_t n, Field& res) const override {
assert(n < size());
sanity_check_simple();
if (res.get_type() == Field::Types::JSONB) {
// Handle JsonbField
res = JsonbField(reinterpret_cast<const char*>(&chars[offset_at(n)]), size_at(n));
Expand All @@ -146,6 +148,7 @@ class ColumnStr final : public COWHelper<IColumn, ColumnStr<T>> {

StringRef get_data_at(size_t n) const override {
DCHECK_LT(n, size());
sanity_check_simple();
return StringRef(&chars[offset_at(n)], size_at(n));
}

Expand Down
6 changes: 6 additions & 0 deletions be/src/vec/exprs/vexpr_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ Status VExprContext::execute(vectorized::Block* block, int* result_column_id) {
RETURN_IF_CATCH_EXCEPTION({
st = _root->execute(this, block, result_column_id);
_last_result_column_id = *result_column_id;
if (_last_result_column_id != -1) {
if (const auto* column_str = check_and_get_column<ColumnString>(
block->get_by_position(*result_column_id).column.get())) {
column_str->sanity_check();
}
}
});
return st;
}
Expand Down
2 changes: 2 additions & 0 deletions be/src/vec/functions/date_time_transforms.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ struct TransformerToStringOneArgument {
cast_set<UInt32>(Transform::execute(date_time_value, res_data, offset));
null_map[i] = !date_time_value.is_valid_date();
}
res_data.resize(res_offsets[res_offsets.size() - 1]);
}

static void vector(FunctionContext* context,
Expand All @@ -336,6 +337,7 @@ struct TransformerToStringOneArgument {
cast_set<UInt32>(Transform::execute(date_time_value, res_data, offset));
DCHECK(date_time_value.is_valid_date());
}
res_data.resize(res_offsets[res_offsets.size() - 1]);
}
};

Expand Down
3 changes: 3 additions & 0 deletions be/test/vec/function/function_test_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ Status check_function(const std::string& func_name, const InputTypeSet& input_ty
// 3. check the result of function
ColumnPtr column = block.get_columns()[result];
EXPECT_TRUE(column);
if (const auto* column_str = check_and_get_column<ColumnString>(column.get())) {
column_str->sanity_check();
}

for (int i = 0; i < row_size; ++i) {
// update current line
Expand Down
Loading