You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/05/12 03:14:21 UTC

[GitHub] [incubator-doris] cambyzju commented on a diff in pull request #9466: [feature-wip][array-type] Support more sub types.

cambyzju commented on code in PR #9466:
URL: https://github.com/apache/incubator-doris/pull/9466#discussion_r870911684


##########
be/src/vec/core/block.cpp:
##########
@@ -768,20 +768,38 @@ void Block::deep_copy_slot(void* dst, MemPool* pool, const doris::TypeDescriptor
         }
         auto item_column = array_column->get_data_ptr().get();
         auto offset = array_column->get_offsets()[row - 1];
+        auto iterator = collection_value->iterator(item_type_desc.type);
         for (int i = 0; i < collection_value->length(); ++i) {
-            char* item_dst = reinterpret_cast<char*>(collection_value->mutable_data()) +
-                             i * item_type_desc.get_slot_size();
             if (array[i].is_null()) {
                 const auto& null_value = doris_udf::AnyVal(true);
-                collection_value->set(i, item_type_desc.type, &null_value);
+                iterator.set(&null_value);
             } else {
                 auto item_offset = offset + i;
                 const auto& data_ref = item_type_desc.type != TYPE_ARRAY
                                                ? item_column->get_data_at(item_offset)
                                                : StringRef();
-                deep_copy_slot(item_dst, pool, item_type_desc, data_ref, item_column, item_offset,
-                               padding_char);
+                if (!item_type_desc.is_date_type() && !item_type_desc.is_decimal_type()) {
+                    deep_copy_slot(iterator.get(), pool, item_type_desc, data_ref, item_column,
+                                   item_offset, padding_char);
+                } else if (item_type_desc.is_date_type()) {
+                    // In CollectionValue, date type data is stored as either uint24_t or uint64_t.
+                    DateTimeValue datetime_value;
+                    deep_copy_slot(&datetime_value, pool, item_type_desc, data_ref, item_column,
+                                   item_offset, padding_char);
+                    DateTimeVal datetime_val;
+                    datetime_value.to_datetime_val(&datetime_val);
+                    iterator.set(&datetime_val);
+                } else {

Review Comment:
   it is better use: if (is_data_type); else if (is_decimal_type); else (others);



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org