ZhangHuiGui commented on code in PR #41380:
URL: https://github.com/apache/arrow/pull/41380#discussion_r1591768405
##########
cpp/src/arrow/compute/kernels/scalar_if_else.cc:
##########
@@ -1482,39 +1482,26 @@ Status ExecScalarCaseWhen(KernelContext* ctx, const
ExecSpan& batch, ExecResult*
result = temp.get();
}
- // TODO(wesm): clean this up to have less duplication
- if (out->is_array_data()) {
- ArrayData* output = out->array_data().get();
- if (is_dictionary_type<Type>::value) {
- const ExecValue& dict_from = has_result ? result : batch[1];
- if (dict_from.is_scalar()) {
- output->dictionary = checked_cast<const
DictionaryScalar&>(*dict_from.scalar)
- .value.dictionary->data();
- } else {
- output->dictionary = dict_from.array.ToArrayData()->dictionary;
- }
- }
- CopyValues<Type>(result, /*in_offset=*/0, batch.length,
- output->GetMutableValues<uint8_t>(0, 0),
- output->GetMutableValues<uint8_t>(1, 0), output->offset);
- } else {
- // ArraySpan
- ArraySpan* output = out->array_span_mutable();
- if (is_dictionary_type<Type>::value) {
- const ExecValue& dict_from = has_result ? result : batch[1];
- output->child_data.resize(1);
- if (dict_from.is_scalar()) {
- output->child_data[0].SetMembers(
- *checked_cast<const DictionaryScalar&>(*dict_from.scalar)
- .value.dictionary->data());
- } else {
- output->child_data[0] = dict_from.array;
- }
+ // Only input types of non-fixed length (which cannot be pre-allocated)
+ // will save the output data in ArrayData. And make sure the FixedLength
+ // types must be output in ArraySpan.
Review Comment:
Agree! Thanks.
--
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]