Skip to content

Commit d1de99e

Browse files
committed
test(parquet): use designated initializers in dictionary tests
1 parent 119e9c0 commit d1de99e

1 file changed

Lines changed: 26 additions & 21 deletions

File tree

‎src/iceberg/test/parquet_row_group_filter_test.cc‎

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ class DictionaryRecordingStream : public SeekableInputStream {
7171
Status Seek(int64_t position) override { return stream_->Seek(position); }
7272
Result<int64_t> Read(std::span<std::byte> out) override {
7373
ICEBERG_ASSIGN_OR_RAISE(auto position, stream_->Position());
74-
reads_.push_back({position, static_cast<int64_t>(out.size())});
74+
reads_.push_back({.offset = position, .length = static_cast<int64_t>(out.size())});
7575
return stream_->Read(out);
7676
}
7777
Status ReadFully(int64_t position, std::span<std::byte> out) override {
78-
reads_.push_back({position, static_cast<int64_t>(out.size())});
78+
reads_.push_back({.offset = position, .length = static_cast<int64_t>(out.size())});
7979
return stream_->ReadFully(position, out);
8080
}
8181
Status Close() override { return stream_->Close(); }
@@ -1399,14 +1399,15 @@ TEST_F(ParquetDictionaryFilterTest, MissingAndTruncatedDictionaryReturnErrors) {
13991399
int64_t start = column->dictionary_page_offset();
14001400
int64_t end = column->data_page_offset();
14011401
int64_t size = input->GetSize().ValueOrDie();
1402-
for (const auto& range : std::vector<DictionaryReadRange>{{-1, end},
1403-
{0, end},
1404-
{start, start},
1405-
{end, start},
1406-
{start, size + 1},
1407-
{start, start + 1},
1408-
{start, end - 1},
1409-
{end, end + 1}}) {
1402+
for (const auto& range :
1403+
std::vector<DictionaryReadRange>{{.offset = -1, .length = end},
1404+
{.offset = 0, .length = end},
1405+
{.offset = start, .length = start},
1406+
{.offset = end, .length = start},
1407+
{.offset = start, .length = size + 1},
1408+
{.offset = start, .length = start + 1},
1409+
{.offset = start, .length = end - 1},
1410+
{.offset = end, .length = end + 1}}) {
14101411
SCOPED_TRACE(std::to_string(range.offset) + ":" + std::to_string(range.length));
14111412
auto rebuilt = RebuildMetadata(false, true, range.offset, range.length);
14121413
EXPECT_FALSE(filter
@@ -1464,8 +1465,9 @@ TEST_F(ParquetDictionaryFilterTest, OpenReadsOnlyDictionaryPage) {
14641465
FileFormatType::kParquet,
14651466
Options(Expressions::Equal("key", Literal::Int(value)))));
14661467
auto expected = footer_reads;
1467-
expected.push_back({column->dictionary_page_offset(),
1468-
column->data_page_offset() - column->dictionary_page_offset()});
1468+
expected.push_back(
1469+
{.offset = column->dictionary_page_offset(),
1470+
.length = column->data_page_offset() - column->dictionary_page_offset()});
14691471
EXPECT_EQ(io->reads, expected);
14701472
ASSERT_THAT(reader->Close(), IsOk());
14711473
}
@@ -1477,15 +1479,18 @@ TEST_F(ParquetDictionaryFilterTest, UnreadableStatisticsRetainNegativePredicates
14771479
std::string json;
14781480
std::vector<std::shared_ptr<Expression>> predicates;
14791481
};
1480-
for (const auto& test : std::vector<Case>{
1481-
{int32(),
1482-
"[[5,0],[5,1]]",
1483-
{Expressions::NotEqual("key", Literal::Int(5)),
1484-
Expressions::NotIn("key", {Literal::Int(5), Literal::Int(6)})}},
1485-
{float64(), "[[NaN,0],[NaN,1]]", {Expressions::NotNaN("key")}},
1486-
{string(),
1487-
R"([["abc",0],["abc",1]])",
1488-
{Expressions::NotStartsWith("key", "a")}}}) {
1482+
for (const auto& test :
1483+
std::vector<Case>{{.type = int32(),
1484+
.json = "[[5,0],[5,1]]",
1485+
.predicates = {Expressions::NotEqual("key", Literal::Int(5)),
1486+
Expressions::NotIn(
1487+
"key", {Literal::Int(5), Literal::Int(6)})}},
1488+
{.type = float64(),
1489+
.json = "[[NaN,0],[NaN,1]]",
1490+
.predicates = {Expressions::NotNaN("key")}},
1491+
{.type = string(),
1492+
.json = R"([["abc",0],["abc",1]])",
1493+
.predicates = {Expressions::NotStartsWith("key", "a")}}}) {
14891494
SetKeyType(test.type);
14901495
ASSERT_THAT(Write(true, test.json), IsOk());
14911496
auto rebuilt = RebuildMetadata(true);

0 commit comments

Comments
 (0)