Skip to content

Commit 32b0fd6

Browse files
committed
upd
1 parent d336eed commit 32b0fd6

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

be/src/vec/columns/column.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@
2121
#include "vec/columns/column.h"
2222

2323
#include "util/simd/bits.h"
24+
#include "vec/columns/column_array.h"
2425
#include "vec/columns/column_const.h"
26+
#include "vec/columns/column_map.h"
2527
#include "vec/columns/column_nullable.h"
28+
#include "vec/columns/column_struct.h"
2629
#include "vec/core/sort_block.h"
2730
#include "vec/data_types/data_type.h"
2831

@@ -89,6 +92,41 @@ bool IColumn::null_map_check() const {
8992
return is_valid;
9093
}
9194

95+
bool IColumn::complex_type_data_nullable_check() const {
96+
auto check_complex_data_is_nullable = [&](const IColumn& subcolumn) {
97+
if (const auto* col_arr = check_and_get_column<ColumnArray>(subcolumn)) {
98+
const auto& data_col = col_arr->get_data();
99+
if (!is_column_nullable(data_col)) {
100+
return false;
101+
}
102+
} else if (const auto* col_map = check_and_get_column<ColumnMap>(subcolumn)) {
103+
const auto& keys_col = col_map->get_keys();
104+
const auto& values_col = col_map->get_values();
105+
if (!is_column_nullable(keys_col) || !is_column_nullable(values_col)) {
106+
return false;
107+
}
108+
} else if (const auto* col_struct = check_and_get_column<ColumnStruct>(subcolumn)) {
109+
const auto& sub_cols = col_struct->get_columns();
110+
for (const auto& c : sub_cols) {
111+
if (!is_column_nullable(*c)) {
112+
return false;
113+
}
114+
}
115+
}
116+
return true;
117+
};
118+
119+
bool is_valid = check_complex_data_is_nullable(*this);
120+
ColumnCallback callback = [&](ColumnPtr& subcolumn) {
121+
if (!subcolumn->complex_type_data_nullable_check()) {
122+
is_valid = false;
123+
}
124+
};
125+
// simply read using for_each_subcolumn without modification; const_cast can be used.
126+
const_cast<IColumn*>(this)->for_each_subcolumn(callback);
127+
return is_valid;
128+
}
129+
92130
Status IColumn::column_self_check() const {
93131
#ifndef NDEBUG
94132
// check const nested
@@ -100,6 +138,11 @@ Status IColumn::column_self_check() const {
100138
if (!null_map_check()) {
101139
return Status::InternalError("null map check failed for column: {}", get_name());
102140
}
141+
// check complex type data nullable
142+
if (!complex_type_data_nullable_check()) {
143+
return Status::InternalError("complex type data nullable check failed for column: {} , {}",
144+
get_name(), dump_structure());
145+
}
103146
#endif
104147
return Status::OK();
105148
}

be/src/vec/columns/column.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,8 @@ class IColumn : public COW<IColumn> {
666666

667667
bool null_map_check() const;
668668

669+
bool complex_type_data_nullable_check() const;
670+
669671
// const column nested check, eg. const(nullable(...)) is allowed
670672
// const(array(const(...))) is not allowed
671673
bool const_nested_check() const;

0 commit comments

Comments
 (0)