Skip to content

Isolate Avro usage in parquet-cli to commands that require Avro #3672

Description

@kevinjqliu

Motivation

parquet-cli still uses Avro as an internal row model in places where users are only trying to inspect Parquet files. Valid Parquet is not always valid Avro, so Parquet inspection should not require Parquet schemas or records to round-trip through Avro.

cat/head already has a group-reader fallback for one class of problem: Avro schema conversion failures such as invalid Avro field names. That fallback is useful, but it is still a special case. Other inspection paths, such as scan, still use the Avro-backed data path for Parquet input.

Concrete examples:

  • Invalid Avro field names: original-instruction and column with known type are valid Parquet field names but invalid Avro names. This already required a cat/head group-reader fallback.
  • Nested Parquet structures: data/nested_lists.snappy.parquet is a valid parquet-testing fixture, but cat and scan fail through the Avro-backed reader.
  • Projection/type mismatch: UUID and INT96 Parquet columns can fail when Avro projection rewrites the requested physical type.
  • Lost Parquet structure: shredded Variant and other newer logical types can have valid Parquet physical structures that Avro cannot represent without losing information.

Avro is still part of the CLI API for conversion workflows. The goal is not to remove Avro; it is to stop requiring Avro for Parquet inspection.

Proposal

Use Avro only when the command or input/output format requires it. Use Parquet-native readers and metadata APIs for Parquet inspection and physical rewrites.

CommandAvro needed?Proposed internal path
help, versionNoCLI metadata only
meta, pages, dictionary, check-stats, column-index, column-size, footer, bloom-filter, size-stats, geospatial-statsNoParquetFileReader and Parquet metadata/page/stat APIs
prune, trans-compression, masking, rewriteNoParquet rewrite utilities
cat, headOnly for non-Parquet inputsParquet -> GroupReadSupport; Avro/JSON -> Avro path
scanOnly for non-Parquet inputsParquet -> GroupReadSupport; Avro/JSON -> Avro path
schemaYes by defaultKeep Avro schema output; keep physical Parquet path for --parquet
csv-schemaYesAvro schema inference
convert-csvYesCSV -> Avro records/schema -> Parquet
convertYesAvro-backed conversion path
to-avroYesAvro writer/schema path

Related issues

Tangential: #2657 and #2630 show additional CLI coupling to Avro internals, but are mostly binary/API mismatch issues.

Summary

Keep Avro for Avro-facing workflows: schema default output, to-avro, convert, CSV/JSON conversion, and Avro input handling.

Use Parquet-native readers for Parquet inspection and physical rewrites. This preserves the Avro API where intentional while making parquet-cli more robust for valid Parquet files that Avro cannot model.

Appendix

Repro examples

Using parquet-mr version 1.17.1 and fixtures from apache/parquet-testing:

git clone https://github.com/apache/parquet-testing.git
cd parquet-testing

These Parquet inspection commands currently fail:

parquet cat -n 1 data/nested_lists.snappy.parquet
parquet scan data/nested_lists.snappy.parquet
parquet cat -n 1 shredded_variant/case-001.parquet
parquet scan shredded_variant/case-001.parquet
parquet cat -n 1 data/int96_from_spark.parquet
parquet scan data/int96_from_spark.parquet

Observed failure classes:

  • data/nested_lists.snappy.parquet: Avro schema conversion succeeds, but cat and scan fail during Avro-backed record reading with ParquetDecodingException, followed by GroupColumnIO.getFirst index failure.
  • shredded_variant/case-001.parquet: Avro schema conversion succeeds, but cat and scan fail during Avro-backed record reading with ParquetDecodingException, followed by GroupColumnIO.getLast index failure.
  • data/int96_from_spark.parquet: Avro schema conversion fails before reading records with Argument error: INT96 is deprecated..., blocking Parquet row inspection.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions