andygrove commented on code in PR #816:
URL: https://github.com/apache/datafusion-comet/pull/816#discussion_r1714404979
##########
native/core/src/execution/operators/copy.rs:
##########
@@ -200,3 +217,56 @@ impl RecordBatchStream for CopyStream {
self.schema.clone()
}
}
+
+/// Copy an Arrow Array
+fn copy_array(array: &dyn Array) -> ArrayRef {
+ let capacity = array.len();
+ let data = array.to_data();
+
+ let mut mutable = MutableArrayData::new(vec![&data], false, capacity);
+
+ mutable.extend(0, 0, capacity);
+
+ if matches!(array.data_type(), DataType::Dictionary(_, _)) {
+ let copied_dict = make_array(mutable.freeze());
+ let ref_copied_dict = &copied_dict;
+
+ downcast_dictionary_array!(
+ ref_copied_dict => {
+ // Copying dictionary value array
+ let values = ref_copied_dict.values();
+ let data = values.to_data();
+
+ let mut mutable = MutableArrayData::new(vec![&data], false,
values.len());
+ mutable.extend(0, 0, values.len());
+
+ let copied_dict =
ref_copied_dict.with_values(make_array(mutable.freeze()));
+ Arc::new(copied_dict)
+ }
+ t => unreachable!("Should not reach here: {}", t)
+ )
+ } else {
+ make_array(mutable.freeze())
+ }
+}
+
+/// Copy an Arrow Array or cast to primitive type if it is a dictionary array.
+/// This is used for `CopyExec` to copy/cast the input array. If the input
array
+/// is a dictionary array, we will cast the dictionary array to primitive type
+/// (i.e., unpack the dictionary array) and copy the primitive array. If the
input
+/// array is a primitive array, we simply copy the array.
+fn copy_or_unpack_array(array: &Arc<dyn Array>, mode: &CopyMode) ->
Result<ArrayRef, ArrowError> {
Review Comment:
this function was moved from `mod.rs` but was also modified
--
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]