Skip to content

[cli] Split convert into JSON and CSV commands#69

Open
jianguotian wants to merge 5 commits into
apache:mainfrom
jianguotian:feat/mosaic-cli
Open

[cli] Split convert into JSON and CSV commands#69
jianguotian wants to merge 5 commits into
apache:mainfrom
jianguotian:feat/mosaic-cli

Conversation

@jianguotian

@jianguotian jianguotian commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Purpose

CSV is not self-describing, so a column whose values are all empty can be inferred as Arrow Null and fail later when creating a Mosaic file. This PR separates JSON and CSV conversion paths, adds explicit schema support when inference is not enough, and reports invalid conversion inputs earlier with clearer errors.

Changes

  • Keep convert for JSON conversion and add convert-csv for CSV conversion.
  • Add Avro schema support, CSV parsing options, required fields, and multi-file CSV conversion.
  • Improve schema inference and validation for null columns, headers, and incompatible inputs.
  • Update CLI docs and tests for the new conversion behavior.

Tests

  • Added JSON convert tests for schema projection, stats, all-null fields, and fields appearing after initial records.
  • Added CSV convert tests for inferred schema, explicit Avro schema, null-column fallback, required fields, custom headers/no-header mode, ragged rows, empty inputs, multi-file inputs, and validation failures.
  • Ran cargo test -p paimon-mosaic-cli.

mingfeng added 2 commits July 2, 2026 05:49
- restore --stats on convert and convert-csv so converted files keep
  min/max stats for cat --where row-group skipping
- error with the column name when sampled JSON inference cannot type an
  all-null field, instead of the writer's late unsupported-DataType error
- accept .jsonl JSON-lines input again and name the accepted suffixes in
  the rejection message
- with an explicit schema, fail when no schema field matches the CSV
  header or a required field is missing from it, instead of writing
  silent all-null columns
- reject --require together with --schema instead of silently ignoring
  it, and report not-null violations with the schema field name rather
  than a positional reader name
- skip empty CSV shards instead of failing on them (or writing a
  0-column file); error only when every input is empty
- validate Avro decimal scale (0..=precision) at schema parse time
- skip the per-file width scan when the CSV schema was inferred (arrow
  inference already rejects ragged rows)
- cover multi-input, --no-header, ragged rows, empty shards, and the new
  failure modes in e2e tests
- describe the commands on their own terms in README, help text, and
  comments, and bring docs/cli.html in sync with the convert/convert-csv
  split
@jianguotian jianguotian changed the title Align mosaic convert commands with parquet CLI [cli] Split convert into JSON and CSV commands with Avro schema support Jul 3, 2026
@jianguotian jianguotian changed the title [cli] Split convert into JSON and CSV commands with Avro schema support [cli] Split convert into JSON and CSV commands Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant