milesgranger commented on code in PR #14495:
URL: https://github.com/apache/arrow/pull/14495#discussion_r1017723521
##########
cpp/src/arrow/compute/kernels/scalar_nested_test.cc:
##########
@@ -141,16 +148,25 @@ TEST(TestScalarNested, StructField) {
&extract0);
CheckScalar("struct_field", {arr}, ArrayFromJSON(int64(), "[10, 11, 12,
null]"),
&extract20);
+
+ CheckScalar("struct_field", {arr}, ArrayFromJSON(int32(), "[1, null, 3,
null]"),
+ &extract0_field_ref_path);
+ CheckScalar("struct_field", {arr}, ArrayFromJSON(int32(), "[1, null, 3,
null]"),
+ &extract0_field_ref_name);
+ CheckScalar("struct_field", {arr}, ArrayFromJSON(int64(), "[10, 11, 12,
null]"),
+ &extract20_field_ref_nest);
+
EXPECT_RAISES_WITH_MESSAGE_THAT(Invalid,
::testing::HasSubstr("out-of-bounds field
reference"),
CallFunction("struct_field", {arr},
&invalid1));
EXPECT_RAISES_WITH_MESSAGE_THAT(Invalid,
- ::testing::HasSubstr("out-of-bounds field
reference"),
+ ::testing::HasSubstr("No match for
FieldRef"),
Review Comment:
Looked around and tried a bit, but the point at which the context of the
error is being created in `FieldRef::FindAll(const FieldVector& fields) const`
no longer has the context of the `DataType` and thus cannot directly discover
`type.num_fields()` as `CheckIndex` does. May be possible return the
`out_of_range_depth` variable there back out to the call `FindOne(DataType)` in
a error status.
Anyhow, I'd happy to open a JIRA and take it as a follow up if that's
desired. :+1:
A summary of where the new error is coming from:
```cpp
FieldPath field_path;
if (field_ref.IsNested() || field_ref.IsName()) {
// New error happens here in FindOne
ARROW_ASSIGN_OR_RAISE(field_path, field_ref.FindOne(*type));
} else {
field_path = *field_ref.field_path();
}
for (const auto& index : field_path.indices()) {
// Ideally, we get the error from here, CheckIndex
RETURN_NOT_OK(StructFieldFunctor::CheckIndex(index, *type));
type = type->field(index)->type().get();
}
```
--
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]