Skip to content

Commit

Permalink
New tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Newton committed Oct 28, 2024
1 parent f5d08c1 commit d886756
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cpp/src/arrow/compute/kernels/scalar_cast_nested.cc
Original file line number Diff line number Diff line change
Expand Up @@ -349,16 +349,14 @@ struct CastStruct {

std::vector<int> fields_to_select(out_field_count, -1);

// create a set of field names
std::set<std::string> in_field_names;
for (int in_field_index = 0; in_field_index < in_field_count; ++in_field_index) {
in_field_names.insert(in_type.field(in_field_index)->name());
}

int out_field_index = 0;
for (int in_field_index = 0;
in_field_index < in_field_count && out_field_index < out_field_count;
++in_field_index) {
in_field_index < in_field_count && out_field_index < out_field_count;) {
const auto& in_field = in_type.field(in_field_index);
const auto& out_field = out_type.field(out_field_index);
if (in_field->name() == out_field->name()) {
Expand All @@ -367,6 +365,7 @@ struct CastStruct {
in_type.ToString(), " ", out_type.ToString());
}
fields_to_select[out_field_index++] = in_field_index;
in_field_index++;
} else if (in_field_names.count(out_field->name()) == 0) {
if (out_field->nullable()) {
fields_to_select[out_field_index++] = -2;
Expand All @@ -375,6 +374,8 @@ struct CastStruct {
"struct fields don't match or are in the wrong order: Input fields: ",
in_type.ToString(), " output fields: ", out_type.ToString());
}
} else {
in_field_index++;
}
}

Expand Down

0 comments on commit d886756

Please sign in to comment.