This is an automated email from the ASF dual-hosted git repository.

panxiaolei 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 71fa00d1298 [Chore](column) enable sanity_check for 
ColumnNullable/ColumnArray/ColumnMap/ColumnStruct (#51858)
71fa00d1298 is described below

commit 71fa00d1298307720b5ad2cf592e463699cb6286
Author: Pxl <[email protected]>
AuthorDate: Wed Jun 25 11:09:41 2025 +0800

    [Chore](column) enable sanity_check for 
ColumnNullable/ColumnArray/ColumnMap/ColumnStruct (#51858)
    
    ### What problem does this PR solve?
    
    enable sanity_check for
    ColumnNullable/ColumnArray/ColumnMap/ColumnStruct
    
    ### Check List (For Author)
    
    - Test <!-- At least one of them must be included. -->
        - [ ] Regression test
        - [ ] Unit Test
        - [ ] Manual test (add detailed scripts or steps below)
        - [x] No need to test or manual test. Explain why:
    - [ ] This is a refactor/code format and no logic has been changed.
            - [x] Previous test can cover this change.
            - [ ] No code files have been changed.
            - [ ] Other reason <!-- Add your reason?  -->
    
    - Behavior changed:
        - [x] No.
        - [ ] Yes. <!-- Explain the behavior change -->
    
    - Does this need documentation?
        - [x] No.
    - [ ] Yes. <!-- Add document PR link here. eg:
    https://github.com/apache/doris-website/pull/1214 -->
    
    ### Check List (For Reviewer who merge this PR)
    
    - [ ] Confirm the release note
    - [ ] Confirm test cases
    - [ ] Confirm document
    - [ ] Add branch pick label <!-- Add branch pick label that this PR
    should merge into -->
---
 be/src/vec/columns/column.h          |  5 +++++
 be/src/vec/columns/column_array.h    |  5 +++++
 be/src/vec/columns/column_map.h      |  6 ++++++
 be/src/vec/columns/column_nullable.h |  9 +++++++++
 be/src/vec/columns/column_string.h   |  4 ++--
 be/src/vec/columns/column_struct.h   | 12 ++++++++++++
 be/src/vec/exprs/vexpr_context.cpp   |  5 +----
 7 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/be/src/vec/columns/column.h b/be/src/vec/columns/column.h
index 7828ac46445..dcdce26ae68 100644
--- a/be/src/vec/columns/column.h
+++ b/be/src/vec/columns/column.h
@@ -72,6 +72,11 @@ public:
     /// Name of a Column. It is used in info messages.
     virtual std::string get_name() const = 0;
 
+    // used to check the column data is valid or not.
+    virtual void sanity_check() const {
+        // do nothing by default, but some column may need to check
+    }
+
     /** If column isn't constant, returns nullptr (or itself).
       * If column is constant, transforms constant to full column (if column 
type allows such transform) and return it.
       */
diff --git a/be/src/vec/columns/column_array.h 
b/be/src/vec/columns/column_array.h
index 5511e0504c6..072c4098771 100644
--- a/be/src/vec/columns/column_array.h
+++ b/be/src/vec/columns/column_array.h
@@ -111,6 +111,11 @@ public:
         return Base::create(std::forward<Args>(args)...);
     }
 
+    void sanity_check() const override {
+        data->sanity_check();
+        offsets->sanity_check();
+    }
+
     void shrink_padding_chars() override;
 
     /** On the index i there is an offset to the beginning of the i + 1 -th 
element. */
diff --git a/be/src/vec/columns/column_map.h b/be/src/vec/columns/column_map.h
index ada5ff70441..70aece03c79 100644
--- a/be/src/vec/columns/column_map.h
+++ b/be/src/vec/columns/column_map.h
@@ -79,6 +79,12 @@ public:
         callback(offsets_column);
     }
 
+    void sanity_check() const override {
+        keys_column->sanity_check();
+        values_column->sanity_check();
+        offsets_column->sanity_check();
+    }
+
     void clear() override {
         keys_column->clear();
         values_column->clear();
diff --git a/be/src/vec/columns/column_nullable.h 
b/be/src/vec/columns/column_nullable.h
index 321b78b1aa8..8a06a85262b 100644
--- a/be/src/vec/columns/column_nullable.h
+++ b/be/src/vec/columns/column_nullable.h
@@ -143,6 +143,15 @@ public:
         return Base::create(std::forward<Args>(args)...);
     }
 
+    void sanity_check() const override {
+        if (nested_column->size() != get_null_map_data().size()) {
+            throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                                   "Size of nested column {} is not equal to 
size of null map {}",
+                                   nested_column->size(), 
get_null_map_data().size());
+        }
+        nested_column->sanity_check();
+    }
+
     void shrink_padding_chars() override;
 
     bool is_variable_length() const override { return 
nested_column->is_variable_length(); }
diff --git a/be/src/vec/columns/column_string.h 
b/be/src/vec/columns/column_string.h
index 07aaee81fe7..77546ee1207 100644
--- a/be/src/vec/columns/column_string.h
+++ b/be/src/vec/columns/column_string.h
@@ -109,8 +109,8 @@ private:
 
 public:
     bool is_variable_length() const override { return true; }
-    // used in string ut testd
-    void sanity_check() const;
+
+    void sanity_check() const override;
     void sanity_check_simple() const;
 
     std::string get_name() const override { return "String"; }
diff --git a/be/src/vec/columns/column_struct.h 
b/be/src/vec/columns/column_struct.h
index eb7dba98c9a..8fd020f6af4 100644
--- a/be/src/vec/columns/column_struct.h
+++ b/be/src/vec/columns/column_struct.h
@@ -85,6 +85,18 @@ public:
     MutableColumnPtr clone_resized(size_t size) const override;
     size_t size() const override { return columns.at(0)->size(); }
 
+    void sanity_check() const override {
+        for (size_t i = 0; i < columns.size(); ++i) {
+            columns[i]->sanity_check();
+            if (i != 0 && columns[i]->size() != columns[0]->size()) {
+                throw doris::Exception(
+                        ErrorCode::INTERNAL_ERROR,
+                        "Size of sub column({}) is not equal to size of first 
column({})",
+                        columns[i]->size(), columns[0]->size());
+            }
+        }
+    }
+
     bool is_variable_length() const override { return true; }
 
     bool is_exclusive() const override {
diff --git a/be/src/vec/exprs/vexpr_context.cpp 
b/be/src/vec/exprs/vexpr_context.cpp
index ae277dd848e..82db6838d04 100644
--- a/be/src/vec/exprs/vexpr_context.cpp
+++ b/be/src/vec/exprs/vexpr_context.cpp
@@ -63,10 +63,7 @@ Status VExprContext::execute(vectorized::Block* block, int* 
result_column_id) {
         _last_result_column_id = *result_column_id;
         // We should first check the status, as some expressions might 
incorrectly set result_column_id, even if the st is not ok.
         if (st.ok() && _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();
-            }
+            block->get_by_position(*result_column_id).column->sanity_check();
         }
     });
     return st;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to