diff --git a/cmd/parquet-cli/cmd_dump.go b/cmd/parquet-cli/cmd_dump.go index 9c77f73..4cf23b0 100644 --- a/cmd/parquet-cli/cmd_dump.go +++ b/cmd/parquet-cli/cmd_dump.go @@ -1,7 +1,6 @@ package main import ( - "errors" "os" "github.com/stoewer/parquet-cli/pkg/inspect" @@ -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 @@ -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}) } diff --git a/pkg/inspect/row_dump.go b/pkg/inspect/row_dump.go index 8dbd841..cb1e4df 100644 --- a/pkg/inspect/row_dump.go +++ b/pkg/inspect/row_dump.go @@ -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 { @@ -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 @@ -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