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/06/06 04:01:01 UTC

[GitHub] [incubator-doris] HappenLee commented on a diff in pull request #9856: [feature-wip](array-type) Add array type support for vectorized parquet-orc scanner

HappenLee commented on code in PR #9856:
URL: https://github.com/apache/incubator-doris/pull/9856#discussion_r889806014


##########
be/src/vec/functions/function_cast.h:
##########
@@ -1040,6 +1073,69 @@ class FunctionCast final : public IFunctionBase {
         };
     }
 
+    WrapperType create_array_wrapper(const DataTypePtr& from_type_untyped,
+                                     const DataTypeArray& to_type) const {
+        /// Conversion from String through parsing.
+        if (check_and_get_data_type<DataTypeString>(from_type_untyped.get())) {
+            return &ConvertImplGenericFromString<ColumnString>::execute;
+        }
+
+        const auto* from_type = check_and_get_data_type<DataTypeArray>(from_type_untyped.get());
+
+        if (!from_type) {
+            LOG(FATAL) << "CAST AS Array can only be performed between same-dimensional Array, "
+                          "String types";
+        }
+
+        DataTypePtr from_nested_type = from_type->get_nested_type();
+
+        /// In query SELECT CAST([] AS Array(Array(String))) from type is Array(Nothing)

Review Comment:
   here may cast `[Array String]` to `[Array Int]`, but the `string` cast to `int` may lead to `NULL`, how to handle it?



##########
be/src/vec/utils/arrow_column_to_doris_column.cpp:
##########
@@ -236,19 +237,51 @@ static Status convert_column_with_decimal_data(const arrow::Array* array, size_t
     return Status::OK();
 }
 
+static Status convert_offset_from_list_column(const arrow::Array* array, size_t array_idx,
+                                              MutableColumnPtr& data_column, size_t num_elements,
+                                              size_t* start_idx_for_data, size_t* num_for_data) {
+    auto& offsets_data = static_cast<ColumnArray&>(*data_column).get_offsets();
+    auto concrete_array = down_cast<const arrow::ListArray*>(array);
+    auto arrow_offsets_array = concrete_array->offsets();
+    auto arrow_offsets = down_cast<arrow::Int32Array*>(arrow_offsets_array.get());
+    for (int64_t i = array_idx + 1; i < array_idx + num_elements + 1; ++i) {
+        offsets_data.emplace_back(arrow_offsets->Value(i));

Review Comment:
   the offset is offset of `arrow::ListArray`, seems not the correct offset of `data_column` ?



-- 
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