diff --git a/cpp/src/arrow/stl.h b/cpp/src/arrow/stl.h index e906d797224df..8ed58f30c8ea9 100644 --- a/cpp/src/arrow/stl.h +++ b/cpp/src/arrow/stl.h @@ -207,7 +207,7 @@ struct ConversionTraits> ::arrow::internal::checked_cast(*array.values()); std::array arr; - for (int64_t i = 0; i < N; i++) { + for (size_t i = 0; i < N; i++) { arr[i] = stl::ConversionTraits::GetEntry(value_array, array.value_offset(j) + i); } diff --git a/cpp/src/arrow/stl_test.cc b/cpp/src/arrow/stl_test.cc index 95e895b435e4e..ce5adf0c0e268 100644 --- a/cpp/src/arrow/stl_test.cc +++ b/cpp/src/arrow/stl_test.cc @@ -253,7 +253,6 @@ TEST(TestTableFromTupleVector, FixedSizeListType) { std::shared_ptr expected_array = ArrayFromJSON(fixed_size_list(int64(), 4), "[[1, 1, 2, 34], [2, -4, 1, 1]]"); std::shared_ptr expected_table = Table::Make(expected_schema, {expected_array}); - std::cout << expected_table->ToString() << std::endl; std::vector rows{tuple_type(std::array{1, 1, 2, 34}), tuple_type(std::array{2, -4, 1, 1})}; @@ -261,8 +260,9 @@ TEST(TestTableFromTupleVector, FixedSizeListType) { std::shared_ptr
table; ASSERT_OK(TableFromTupleRange(default_memory_pool(), rows, names, &table)); + ASSERT_OK(table->ValidateFull()); - ASSERT_TRUE(expected_table->Equals(*table)); + AssertTablesEqual(*expected_table, *table); } TEST(TestTableFromTupleVector, ReferenceTuple) { @@ -488,6 +488,26 @@ TEST(TestTupleVectorFromTable, ListType) { ASSERT_EQ(rows, expected_rows); } +TEST(TestTupleVectorFromTable, FixedSizeListType) { + using tuple_type = std::tuple>; + + compute::ExecContext ctx; + compute::CastOptions cast_options; + auto expected_schema = std::make_shared( + FieldVector{field("column1", fixed_size_list(int64(), 4), false)}); + std::shared_ptr expected_array = + ArrayFromJSON(fixed_size_list(int64(), 4), "[[1, 1, 2, 34], [2, -4, 1, 1]]"); + std::shared_ptr
table = Table::Make(expected_schema, {expected_array}); + ASSERT_OK(table->ValidateFull()); + + std::vector expected_rows{tuple_type(std::array{1, 1, 2, 34}), + tuple_type(std::array{2, -4, 1, 1})}; + + std::vector rows(2); + ASSERT_OK(TupleRangeFromTable(*table, cast_options, &ctx, &rows)); + ASSERT_EQ(rows, expected_rows); +} + TEST(TestTupleVectorFromTable, CastingNeeded) { using tuple_type = std::tuple>; diff --git a/cpp/src/arrow/type_traits.h b/cpp/src/arrow/type_traits.h index 3f07b461a574d..92009c8560c4e 100644 --- a/cpp/src/arrow/type_traits.h +++ b/cpp/src/arrow/type_traits.h @@ -540,6 +540,7 @@ struct CTypeTraits> : public TypeTraits { } }; +/// \addtogroup c-type-traits template struct CTypeTraits> : public TypeTraits { using ArrowType = FixedSizeListType;