BiteTheDDDDt commented on code in PR #13273:
URL: https://github.com/apache/doris/pull/13273#discussion_r995308928
##########
be/src/olap/schema_change.cpp:
##########
@@ -834,8 +834,34 @@ Status RowBlockChanger::change_block(vectorized::Block*
ref_block,
}
for (auto it : swap_idx_map) {
- new_block->get_by_position(it.second).column.swap(
- ref_block->get_by_position(it.first).column);
+ auto& ref_col = ref_block->get_by_position(it.first);
+ auto& new_col = new_block->get_by_position(it.second);
+
+ bool ref_col_nullable = ref_col.column->is_nullable();
+ bool new_col_nullable = new_col.column->is_nullable();
+
+ if (ref_col_nullable != new_col_nullable) {
+ // not nullable to nullable
+ if (new_col_nullable) {
+ auto* new_nullable_col =
assert_cast<vectorized::ColumnNullable*>(
+ std::move(*new_col.column).mutate().get());
+
+ new_nullable_col->swap_nested_column(ref_col.column);
+
new_nullable_col->get_null_map_data().resize_fill(new_nullable_col->size());
+ } else {
+ // nullable to not nullable:
Review Comment:
It is best to add a logic to check that the nullmap does not contain null.
If there is null data, the schema change will fail to prevent accidental data
loss.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]