@@ -614,13 +614,28 @@ TEST_F(TestRecordBatch, FromSlicedStructArray) {
614614 StructArray struct_array (struct_ ({field (" x" , int64 ())}), kLength , {x_arr});
615615 std::shared_ptr<Array> sliced = struct_array.Slice (5 , 3 );
616616 ASSERT_OK_AND_ASSIGN (auto batch, RecordBatch::FromStructArray (sliced));
617+ ASSERT_OK (batch->ValidateFull ());
617618
618619 std::shared_ptr<Array> expected_arr = ArrayFromJSON (int64 (), " [5, 6, 7]" );
619620 std::shared_ptr<RecordBatch> expected =
620621 RecordBatch::Make (schema ({field (" x" , int64 ())}), 3 , {expected_arr});
621622 AssertBatchesEqual (*expected, *batch);
622623}
623624
625+ TEST_F (TestRecordBatch, FromSlicedStructArrayWithOffsetZero) {
626+ static constexpr int64_t kLength = 5 ;
627+ std::shared_ptr<Array> x_arr = ArrayFromJSON (int64 (), " [0, 1, 2, 3, 4]" );
628+ StructArray struct_array (struct_ ({field (" x" , int64 ())}), kLength , {x_arr});
629+ std::shared_ptr<Array> sliced = struct_array.Slice (0 , 3 );
630+ ASSERT_OK_AND_ASSIGN (auto batch, RecordBatch::FromStructArray (sliced));
631+ ASSERT_OK (batch->ValidateFull ());
632+
633+ std::shared_ptr<Array> expected_arr = ArrayFromJSON (int64 (), " [0, 1, 2]" );
634+ std::shared_ptr<RecordBatch> expected =
635+ RecordBatch::Make (schema ({field (" x" , int64 ())}), 3 , {expected_arr});
636+ AssertBatchesEqual (*expected, *batch);
637+ }
638+
624639TEST_F (TestRecordBatch, FromStructArrayInvalidType) {
625640 random::RandomArrayGenerator gen (42 );
626641 ASSERT_RAISES (TypeError, RecordBatch::FromStructArray (gen.ArrayOf (int32 (), 6 )));
0 commit comments