Skip to content

Commit 06266f9

Browse files
committed
address review
1 parent 3840ffc commit 06266f9

1 file changed

Lines changed: 43 additions & 80 deletions

File tree

cpp/src/parquet/arrow/arrow_reader_writer_test.cc

Lines changed: 43 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -3395,91 +3395,54 @@ TEST(ArrowReadWrite, EmptyListView) {
33953395
ASSERT_EQ(0, list_view.value_sizes()->size());
33963396
}
33973397

3398-
TEST(ArrowReadWrite, FixedSizeList) {
3399-
using ::arrow::field;
3400-
using ::arrow::fixed_size_list;
3401-
using ::arrow::struct_;
3402-
3403-
auto type = fixed_size_list(::arrow::int16(), /*size=*/3);
3404-
3405-
const char* json = R"([
3406-
[1, 2, 3],
3407-
[4, 5, 6],
3408-
[7, 8, 9]])";
3409-
auto array = ::arrow::ArrayFromJSON(type, json);
3410-
auto table = ::arrow::Table::Make(::arrow::schema({field("root", type)}), {array});
3411-
auto props_store_schema = ArrowWriterProperties::Builder().store_schema()->build();
3412-
CheckSimpleRoundtrip(table, 2, props_store_schema);
3413-
}
3414-
3415-
TEST(ArrowReadWrite, FixedSizeListNull) {
3416-
using ::arrow::field;
3417-
using ::arrow::fixed_size_list;
3418-
3419-
auto type = fixed_size_list(::arrow::int16(), /*size=*/3);
3420-
3421-
const char* json = R"([
3422-
null,
3423-
[1, 2, 3],
3424-
null,
3425-
[4, 5, 6],
3426-
null])";
3427-
auto array = ::arrow::ArrayFromJSON(type, json);
3428-
auto table = ::arrow::Table::Make(::arrow::schema({field("root", type)}), {array});
3429-
auto props_store_schema = ArrowWriterProperties::Builder().store_schema()->build();
3430-
CheckSimpleRoundtrip(table, 2, props_store_schema);
3431-
}
3432-
3433-
TEST(ArrowReadWrite, FixedSizeListAllNull) {
3434-
using ::arrow::field;
3435-
using ::arrow::fixed_size_list;
3436-
3437-
auto type = fixed_size_list(::arrow::int16(), /*size=*/3);
3398+
struct FixedSizeListTestCase {
3399+
std::shared_ptr<DataType> type;
3400+
std::string json;
3401+
};
34383402

3439-
const char* json = R"([
3440-
null,
3441-
null,
3442-
null])";
3443-
auto array = ::arrow::ArrayFromJSON(type, json);
3444-
auto table = ::arrow::Table::Make(::arrow::schema({field("root", type)}), {array});
3403+
class TestFixedSizeListRoundTrip
3404+
: public ::testing::TestWithParam<FixedSizeListTestCase> {};
3405+
3406+
static const std::vector<FixedSizeListTestCase> kFixedSizeListTestCases = {
3407+
{.type = ::arrow::fixed_size_list(::arrow::int16(), /*list_size=*/3), .json = R"([
3408+
{"root": [1, 2, 3]},
3409+
{"root": [4, 5, 6]},
3410+
{"root": [7, 8, 9]}])"},
3411+
{.type = ::arrow::fixed_size_list(::arrow::int16(), /*list_size=*/3), .json = R"([
3412+
{"root": null},
3413+
{"root": [1, 2, 3]},
3414+
{"root": null},
3415+
{"root": [4, 5, 6]},
3416+
{"root": null}])"},
3417+
{.type = ::arrow::fixed_size_list(::arrow::int16(), /*list_size=*/3), .json = R"([
3418+
{"root": null},
3419+
{"root": null},
3420+
{"root": null}])"},
3421+
{.type = ::arrow::fixed_size_list(
3422+
::arrow::fixed_size_list(::arrow::int16(), /*list_size=*/2),
3423+
/*list_size=*/2),
3424+
.json = R"([
3425+
{"root": [[1, 2], [3, 4]]},
3426+
{"root": null},
3427+
{"root": [[5, 6], null]},
3428+
{"root": [null, [7, 8]]}])"},
3429+
{.type = ::arrow::list(::arrow::fixed_size_list(::arrow::int16(), /*list_size=*/2)),
3430+
.json = R"([
3431+
{"root": [[1, 2], null, [3, 4]]},
3432+
{"root": null},
3433+
{"root": [null, [5, 6]]},
3434+
{"root": []}])"}};
3435+
3436+
TEST_P(TestFixedSizeListRoundTrip, RoundTrip) {
3437+
const auto& test_case = GetParam();
3438+
auto table = ::arrow::TableFromJSON(
3439+
::arrow::schema({::arrow::field("root", test_case.type)}), {test_case.json});
34453440
auto props_store_schema = ArrowWriterProperties::Builder().store_schema()->build();
34463441
CheckSimpleRoundtrip(table, 2, props_store_schema);
34473442
}
34483443

3449-
TEST(ArrowReadWrite, NestedFixedSizeList) {
3450-
using ::arrow::field;
3451-
using ::arrow::fixed_size_list;
3452-
3453-
auto type = fixed_size_list(fixed_size_list(::arrow::int16(), 2), /*size=*/2);
3454-
3455-
const char* json = R"([
3456-
[[1, 2], [3, 4]],
3457-
null,
3458-
[[5, 6], null],
3459-
[null, [7, 8]]])";
3460-
auto array = ::arrow::ArrayFromJSON(type, json);
3461-
auto table = ::arrow::Table::Make(::arrow::schema({field("root", type)}), {array});
3462-
auto props_store_schema = ArrowWriterProperties::Builder().store_schema()->build();
3463-
CheckSimpleRoundtrip(table, 2, props_store_schema);
3464-
}
3465-
3466-
TEST(ArrowReadWrite, ListOfFixedSizeList) {
3467-
using ::arrow::field;
3468-
using ::arrow::fixed_size_list;
3469-
using ::arrow::list;
3470-
3471-
auto type = list(fixed_size_list(::arrow::int16(), 2));
3472-
3473-
const char* json = R"([
3474-
[[1, 2], null, [3, 4]],
3475-
null,
3476-
[null, [5, 6]],
3477-
[]])";
3478-
auto array = ::arrow::ArrayFromJSON(type, json);
3479-
auto table = ::arrow::Table::Make(::arrow::schema({field("root", type)}), {array});
3480-
auto props_store_schema = ArrowWriterProperties::Builder().store_schema()->build();
3481-
CheckSimpleRoundtrip(table, 2, props_store_schema);
3482-
}
3444+
INSTANTIATE_TEST_SUITE_P(ArrowReadWrite, TestFixedSizeListRoundTrip,
3445+
::testing::ValuesIn(kFixedSizeListTestCases));
34833446

34843447
TEST(ArrowReadWrite, ListOfStructOfList2) {
34853448
using ::arrow::field;

0 commit comments

Comments
 (0)