This is an automated email from the ASF dual-hosted git repository.
Mryange 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 9816a5a20b6 [fix](be) Check block column and type pointers (#64721)
9816a5a20b6 is described below
commit 9816a5a20b684128b7333e2aacd3f9d08a97c7be
Author: Mryange <[email protected]>
AuthorDate: Wed Jun 24 10:33:42 2026 +0800
[fix](be) Check block column and type pointers (#64721)
### What problem does this PR solve?
Add an explicit block check to reject null column or type pointers at
operator sink/get_block boundaries, while keeping the existing type
compatibility check unchanged.
### Release note
None
---
be/src/core/block/block.cpp | 15 +++++++++++++++
be/src/core/block/block.h | 2 ++
be/src/exec/operator/operator.h | 2 ++
be/test/core/data_type/block_check_type.cpp | 20 +++++++++++++++++++-
4 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/be/src/core/block/block.cpp b/be/src/core/block/block.cpp
index e0fca38b2bb..d94f6b3a186 100644
--- a/be/src/core/block/block.cpp
+++ b/be/src/core/block/block.cpp
@@ -343,6 +343,21 @@ Status Block::check_type_and_column() const {
return Status::OK();
}
+Status Block::check_column_and_type_not_null() const {
+ for (size_t i = 0; i != data.size(); ++i) {
+ const auto& elem = data[i];
+ if (!elem.column) {
+ return Status::InternalError("Column in block is nullptr, column
index: {}, name: {}",
+ i, elem.name);
+ }
+ if (!elem.type) {
+ return Status::InternalError("Type in block is nullptr, column
index: {}, name: {}", i,
+ elem.name);
+ }
+ }
+ return Status::OK();
+}
+
size_t Block::rows() const {
for (const auto& elem : data) {
if (elem.column) {
diff --git a/be/src/core/block/block.h b/be/src/core/block/block.h
index 6207aa8f49d..3dfef246bba 100644
--- a/be/src/core/block/block.h
+++ b/be/src/core/block/block.h
@@ -183,6 +183,8 @@ public:
Status check_type_and_column() const;
+ Status check_column_and_type_not_null() const;
+
/// Approximate number of bytes used by column data in memory.
/// This reflects the actual data footprint (e.g. string contents, numeric
arrays)
/// and is the metric used by adaptive batch size byte budgets.
diff --git a/be/src/exec/operator/operator.h b/be/src/exec/operator/operator.h
index 85d72ed1147..49018fb57d8 100644
--- a/be/src/exec/operator/operator.h
+++ b/be/src/exec/operator/operator.h
@@ -615,6 +615,7 @@ public:
}
[[nodiscard]] Status sink(RuntimeState* state, Block* block, bool eos) {
+ RETURN_IF_ERROR(block->check_column_and_type_not_null());
RETURN_IF_ERROR(block->check_type_and_column());
return sink_impl(state, block, eos);
}
@@ -876,6 +877,7 @@ public:
Status terminate(RuntimeState* state) override;
[[nodiscard]] Status get_block(RuntimeState* state, Block* block, bool*
eos) {
RETURN_IF_ERROR(get_block_impl(state, block, eos));
+ RETURN_IF_ERROR(block->check_column_and_type_not_null());
RETURN_IF_ERROR(block->check_type_and_column());
return Status::OK();
}
diff --git a/be/test/core/data_type/block_check_type.cpp
b/be/test/core/data_type/block_check_type.cpp
index 2756d8714c7..6915aabb92f 100644
--- a/be/test/core/data_type/block_check_type.cpp
+++ b/be/test/core/data_type/block_check_type.cpp
@@ -39,4 +39,22 @@ TEST(BlockCheckType, test1) {
EXPECT_FALSE(st.ok());
std::cout << st.msg() << std::endl;
}
-} // namespace doris
\ No newline at end of file
+
+TEST(BlockCheckType, CheckColumnAndTypeNotNull) {
+ auto block = Block {
+ ColumnHelper::create_column_with_name<DataTypeInt32>({1, 2, 3, 4}),
+ ColumnHelper::create_column_with_name<DataTypeInt64>({1, 2, 3, 4}),
+ };
+
+ EXPECT_TRUE(block.check_column_and_type_not_null());
+
+ block.get_by_position(0).column = nullptr;
+ auto st = block.check_column_and_type_not_null();
+ EXPECT_FALSE(st.ok());
+
+ block.get_by_position(0).column =
ColumnHelper::create_column<DataTypeInt32>({1, 2, 3, 4});
+ block.get_by_position(1).type = nullptr;
+ st = block.check_column_and_type_not_null();
+ EXPECT_FALSE(st.ok());
+}
+} // namespace doris
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]