Skip to content

Commit

Permalink
autoformat
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Newton committed Oct 30, 2024
1 parent 7feb26e commit 680f224
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 6 additions & 4 deletions cpp/src/arrow/compute/kernels/scalar_cast_nested.cc
Original file line number Diff line number Diff line change
Expand Up @@ -367,16 +367,18 @@ struct CastStruct {
}
// Found matching in_field and out_field.
fields_to_select[out_field_index++] = in_field_index;
// Using the same in_field for multiple out_fields is not allowed.
// Using the same in_field for multiple out_fields is not allowed.
in_field_index++;
continue;
}
}
if (all_in_field_names.count(out_field->name()) == 0 && out_field->nullable()) {
// Didn't match current in_field, but we can fill with null.
// Filling with null is only acceptable on nuallable fields when there
// Didn't match current in_field, but we can fill with null.
// Filling with null is only acceptable on nuallable fields when there
// is definitely no in_field with matching name.
fields_to_select[out_field_index++] = -2; // -2 is a sentinel value for fill with null.

// -2 is a sentinel value indicating fill with null.
fields_to_select[out_field_index++] = -2;
} else if (in_field_index < in_field_count) {
// Didn't match current in_field, and the we cannot fill with null, so
// try next in_field.
Expand Down
5 changes: 3 additions & 2 deletions cpp/src/arrow/compute/kernels/scalar_cast_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2761,8 +2761,9 @@ TEST(Cast, StructToSameSizedButDifferentNamedStruct) {
ASSERT_OK_AND_ASSIGN(auto dest1, StructArray::Make({nulls, nulls}, dest1_field_names));
CheckCast(src, dest1);

const auto dest2 = arrow::struct_(
{std::make_shared<Field>("c", int8(), /*nullable=*/false), std::make_shared<Field>("d", int8())});
const auto dest2 =
arrow::struct_({std::make_shared<Field>("c", int8(), /*nullable=*/false),
std::make_shared<Field>("d", int8())});
const auto options2 = CastOptions::Safe(dest2);

EXPECT_RAISES_WITH_MESSAGE_THAT(
Expand Down

0 comments on commit 680f224

Please sign in to comment.