jorisvandenbossche commented on code in PR #14495:
URL: https://github.com/apache/arrow/pull/14495#discussion_r1006894857
##########
cpp/src/arrow/compute/kernels/scalar_nested.cc:
##########
@@ -271,11 +318,30 @@ struct StructFieldFunctor {
Result<TypeHolder> ResolveStructFieldType(KernelContext* ctx,
const std::vector<TypeHolder>&
types) {
- const auto& options = OptionsWrapper<StructFieldOptions>::Get(ctx);
+ const auto& field_ref =
OptionsWrapper<StructFieldOptions>::Get(ctx).field_ref;
const DataType* type = types.front().type;
- for (const auto& index : options.indices) {
- RETURN_NOT_OK(StructFieldFunctor::CheckIndex(index, *type));
- type = type->field(index)->type().get();
+
+ if (field_ref.IsName()) {
+ for (const auto& path : field_ref.FindAll(*type)) {
+ for (const auto& index : path.indices()) {
+ RETURN_NOT_OK(StructFieldFunctor::CheckIndex(index, *type));
+ type = type->field(index)->type().get();
+ }
+ }
+ } else {
+ DCHECK(field_ref.IsFieldPath() || field_ref.IsNested());
+
+ FieldPath field_path;
+ if (field_ref.IsNested()) {
+ ARROW_ASSIGN_OR_RAISE(field_path, field_ref.FindOne(*type));
+ } else {
+ field_path = *field_ref.field_path();
+ }
Review Comment:
I am wondering if it is actually intentional that we support empty index (I
don't see it covered in the C++ tests?). That doesn't sound very useful? (it
just returns the original array?)
--
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]