Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/parquet inventory failure #1979

Merged
merged 4 commits into from
May 23, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions pkg/cloud/aws/s3inventory/parquet_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,29 @@ func (p *ParquetInventoryFileReader) Close() error {
return p.PFile.Close()
}

func (p *ParquetInventoryFileReader) getKeyColumnStatistics() *parquet.Statistics {
for i, c := range p.Footer.RowGroups[0].Columns {
func (p *ParquetInventoryFileReader) getKeyColumnStatistics(rowGroupIdx int) *parquet.Statistics {
for i, c := range p.Footer.RowGroups[rowGroupIdx].Columns {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simplify by replacing all occurrences:

	columns := p.Footer.RowGroups[rowGroupIdx].Columns

and inside the loop:

	metaData := c.GetMetaData()

if c.MetaData.PathInSchema[len(c.GetMetaData().GetPathInSchema())-1] == "Key" {
return p.Footer.RowGroups[0].Columns[i].GetMetaData().GetStatistics()
return p.Footer.RowGroups[rowGroupIdx].Columns[i].GetMetaData().GetStatistics()
}
}
return p.Footer.RowGroups[0].Columns[1].GetMetaData().GetStatistics()
return p.Footer.RowGroups[rowGroupIdx].Columns[1].GetMetaData().GetStatistics()
}

func (p *ParquetInventoryFileReader) FirstObjectKey() string {
return string(p.getKeyColumnStatistics().GetMin())
statistics := p.getKeyColumnStatistics(0)
if len(statistics.GetMin()) > 0 {
return string(statistics.GetMin())
}
return string(statistics.GetMinValue())
}

func (p *ParquetInventoryFileReader) LastObjectKey() string {
return string(p.getKeyColumnStatistics().GetMax())
statistics := p.getKeyColumnStatistics(len(p.Footer.RowGroups) - 1)
if len(statistics.GetMax()) > 0 {
return string(statistics.GetMax())
}
return string(statistics.GetMinValue())
}

func (p *ParquetInventoryFileReader) Read(n int) ([]*InventoryObject, error) {
Expand Down