Skip to content

Commit

Permalink
Improve dump sub-command: don't print rep/def levels
Browse files Browse the repository at this point in the history
  • Loading branch information
stoewer committed May 6, 2024
1 parent 41674bd commit cb94934
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
7 changes: 1 addition & 6 deletions cmd/parquet-cli/cmd_dump.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"errors"
"os"

"github.com/stoewer/parquet-cli/pkg/inspect"
Expand All @@ -17,10 +16,6 @@ type dump struct {
}

func (d *dump) Run() error {
if d.Output == output.FormatJSON {
return errors.New("JSON output not supported for dump command")
}

file, err := openParquetFile(d.File)
if err != nil {
return err
Expand All @@ -39,5 +34,5 @@ func (d *dump) Run() error {
return err
}

return output.PrintTable(os.Stdout, d.Output, rowDump)
return output.Print(os.Stdout, rowDump, &output.PrintOptions{Format: d.Output})
}
14 changes: 4 additions & 10 deletions pkg/inspect/row_dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ type DumpLine struct {
Line []*parquet.Value
}

func (d *DumpLine) SerializableData() any {
return d.Line
}

func (d *DumpLine) Cells() []any {
cells := make([]any, 0, len(d.Line)+1)
if d.RowNumber == nil {
Expand All @@ -27,12 +23,10 @@ func (d *DumpLine) Cells() []any {
for _, v := range d.Line {
if v == nil {
cells = append(cells, "")
} else if v.IsNull() {
cells = append(cells, "null")
} else {
if v.IsNull() {
cells = append(cells, fmt.Sprintf("%v %d:%d", v, v.DefinitionLevel(), v.RepetitionLevel()))
} else {
cells = append(cells, fmt.Sprintf("'%v' %d:%d", v, v.DefinitionLevel(), v.RepetitionLevel()))
}
cells = append(cells, v.String())
}
}
return cells
Expand Down Expand Up @@ -74,7 +68,7 @@ func NewRowDump(file *parquet.File, options RowDumpOptions) (*RowDump, error) {
return nil, fmt.Errorf("unable to create row stats calculator: %w", err)
}
c.columnIter = append(c.columnIter, it)
c.header = append(c.header, col.Name()+" d:r")
c.header = append(c.header, col.Name())
}

return &c, nil
Expand Down

0 comments on commit cb94934

Please sign in to comment.