This is an automated email from the ASF dual-hosted git repository. lihaopeng pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 7a85b6d20f8 [Chore](column) fix wrong chars size on TransformerToStringOneArgument and add more check (#48545) 7a85b6d20f8 is described below commit 7a85b6d20f8816fd1475576272960b6cf3ccf8f3 Author: Pxl <x...@selectdb.com> AuthorDate: Thu Mar 6 13:34:07 2025 +0800 [Chore](column) fix wrong chars size on TransformerToStringOneArgument and add more check (#48545) --- be/src/vec/columns/column_string.cpp | 11 ++++++----- be/src/vec/columns/column_string.h | 3 +++ be/src/vec/exprs/vexpr_context.cpp | 6 ++++++ be/src/vec/functions/date_time_transforms.h | 2 ++ be/test/vec/function/function_test_util.h | 3 +++ 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/be/src/vec/columns/column_string.cpp b/be/src/vec/columns/column_string.cpp index ce9bdf0f110..af0b7e14c36 100644 --- a/be/src/vec/columns/column_string.cpp +++ b/be/src/vec/columns/column_string.cpp @@ -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])); @@ -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])); @@ -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 = diff --git a/be/src/vec/columns/column_string.h b/be/src/vec/columns/column_string.h index 134fc647014..dbf2679f15c 100644 --- a/be/src/vec/columns/column_string.h +++ b/be/src/vec/columns/column_string.h @@ -131,11 +131,13 @@ public: 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)); @@ -146,6 +148,7 @@ public: 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)); } diff --git a/be/src/vec/exprs/vexpr_context.cpp b/be/src/vec/exprs/vexpr_context.cpp index ae17ace911b..569d002cb0c 100644 --- a/be/src/vec/exprs/vexpr_context.cpp +++ b/be/src/vec/exprs/vexpr_context.cpp @@ -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; } diff --git a/be/src/vec/functions/date_time_transforms.h b/be/src/vec/functions/date_time_transforms.h index 301effe80e0..63ed635df45 100644 --- a/be/src/vec/functions/date_time_transforms.h +++ b/be/src/vec/functions/date_time_transforms.h @@ -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, @@ -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]); } }; diff --git a/be/test/vec/function/function_test_util.h b/be/test/vec/function/function_test_util.h index 937a873c607..4526f8a7295 100644 --- a/be/test/vec/function/function_test_util.h +++ b/be/test/vec/function/function_test_util.h @@ -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 --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org