Skip to content

Commit 38e3a9a

Browse files
committed
upd
1 parent c80dd34 commit 38e3a9a

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

be/src/vec/columns/column.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,27 @@ std::string IColumn::dump_structure() const {
4343
return res.str();
4444
}
4545

46+
int IColumn::count_const_column() const {
47+
int count = is_column_const(*this) ? 1 : 0;
48+
ColumnCallback callback = [&](ColumnPtr& subcolumn) {
49+
if (is_column_const(*subcolumn)) {
50+
count += 1;
51+
}
52+
};
53+
// simply read using for_each_subcolumn without modification; const_cast can be used.
54+
const_cast<IColumn*>(this)->for_each_subcolumn(callback);
55+
return count;
56+
}
57+
58+
bool IColumn::const_check() const {
59+
auto const_cnt = count_const_column();
60+
if (const_cnt == 0) {
61+
return true;
62+
}
63+
// A const column is not allowed to be nested; it may only appear as the outermost (top-level) column.
64+
return const_cnt == 1 && is_column_const(*this);
65+
}
66+
4667
void IColumn::insert_from(const IColumn& src, size_t n) {
4768
insert(src[n]);
4869
}

be/src/vec/columns/column.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,10 @@ class IColumn : public COW<IColumn> {
647647
*/
648648
String dump_structure() const;
649649

650+
int count_const_column() const;
651+
652+
bool const_check() const;
653+
650654
// only used in agg value replace for column which is not variable length, eg.BlockReader::_copy_value_data
651655
// usage: self_column.replace_column_data(other_column, other_column's row index, self_column's row index)
652656
virtual void replace_column_data(const IColumn&, size_t row, size_t self_row = 0) = 0;

be/src/vec/core/block.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,12 @@ Status Block::check_type_and_column() const {
399399
const auto& type = elem.type;
400400
const auto& column = elem.column;
401401

402+
if (!column->const_check()) {
403+
return Status::InternalError(
404+
"Column {} in block failed const check, data type :{} , column structure",
405+
elem.name, type->get_name(), column->dump_structure());
406+
}
407+
402408
auto st = type->check_column(*column);
403409
if (!st.ok()) {
404410
return Status::InternalError(

0 commit comments

Comments
 (0)