Skip to content

Commit dd29813

Browse files
committed
upd
1 parent d336eed commit dd29813

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

be/src/vec/columns/column.cpp

Lines changed: 41 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_variant.h"
2629
#include "vec/core/sort_block.h"
2730
#include "vec/data_types/data_type.h"
2831

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

95+
bool IColumn::complex_type_data_nullable_check() const {
96+
if (check_and_get_column<ColumnVariant>(*this)) {
97+
// skip check for ColumnVariant
98+
return true;
99+
}
100+
101+
auto check_complex_data_is_nullable = [&](const IColumn& subcolumn) {
102+
if (const auto* col_arr = check_and_get_column<ColumnArray>(subcolumn)) {
103+
const auto& data_col = col_arr->get_data();
104+
if (!is_column_nullable(data_col)) {
105+
return false;
106+
}
107+
} else if (const auto* col_map = check_and_get_column<ColumnMap>(subcolumn)) {
108+
const auto& keys_col = col_map->get_keys();
109+
const auto& values_col = col_map->get_values();
110+
if (!is_column_nullable(keys_col) || !is_column_nullable(values_col)) {
111+
return false;
112+
}
113+
}
114+
return true;
115+
};
116+
117+
bool is_valid = check_complex_data_is_nullable(*this);
118+
ColumnCallback callback = [&](ColumnPtr& subcolumn) {
119+
if (!subcolumn->complex_type_data_nullable_check()) {
120+
is_valid = false;
121+
}
122+
};
123+
// simply read using for_each_subcolumn without modification; const_cast can be used.
124+
const_cast<IColumn*>(this)->for_each_subcolumn(callback);
125+
return is_valid;
126+
}
127+
92128
Status IColumn::column_self_check() const {
93129
#ifndef NDEBUG
94130
// check const nested
@@ -100,6 +136,11 @@ Status IColumn::column_self_check() const {
100136
if (!null_map_check()) {
101137
return Status::InternalError("null map check failed for column: {}", get_name());
102138
}
139+
// check complex type data nullable
140+
if (!complex_type_data_nullable_check()) {
141+
return Status::InternalError("complex type data nullable check failed for column: {} ",
142+
dump_structure());
143+
}
103144
#endif
104145
return Status::OK();
105146
}

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)