imay commented on a change in pull request #2310: Marising
URL: https://github.com/apache/incubator-doris/pull/2310#discussion_r351168660
##########
File path: be/src/olap/schema_change.cpp
##########
@@ -335,12 +336,36 @@ bool RowBlockChanger::change_row_block(
write_helper.set_field_content(i, buf, mem_pool);
}
}
-
+ } else if ( (newtype == OLAP_FIELD_TYPE_DATE && reftype ==
OLAP_FIELD_TYPE_DATETIME)
+ || (newtype == OLAP_FIELD_TYPE_DOUBLE && reftype ==
OLAP_FIELD_TYPE_FLOAT) ) {
+ // 效率低下,也可以直接计算变长域拷贝,但仍然会破坏封装
+ for (size_t row_index = 0, new_row_index = 0;
+ row_index < ref_block->row_block_info().row_num;
++row_index) {
+ // 不需要的row,每次处理到这个row时就跳过
+ if (need_filter_data && is_data_left_vec[row_index] == 0) {
+ continue;
+ }
+ // 指定新的要写入的row index(不同于读的row_index)
+ mutable_block->get_row(new_row_index++, &write_helper);
+ ref_block->get_row(row_index, &read_helper);
+ if ( read_helper.is_null(ref_column) ) {
+ write_helper.set_null(i);
+ }else{
+ write_helper.set_not_null(i);
+ const Field* ref_field=
read_helper.column_schema(ref_column);
+ char* ref_value = read_helper.cell_ptr(ref_column);
+ OLAPStatus st = write_helper.convert_from(i,
ref_value, ref_field->type_info(), mem_pool);
+ if( st != OLAPStatus::OLAP_SUCCESS){
+ LOG(WARNING) << "the column type which was altered
from was unsupported."
+ << "status:" << st << ", from_type=" <<
reftype << ", to_type=" << newtype;
+ }
+ }
+ }
// 从ref_column 写入 i列。
} else {
// copy and alter the field
// 此处可以暂时不动,新类型暂时不涉及类型转换
- switch (ref_block->tablet_schema().column(ref_column).type()) {
+ switch ( reftype ) {
Review comment:
```suggestion
switch (reftype) {
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]