Skip to content
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
947bb61
feat(cli): add mosaic inspector CLI (schema/meta/cat/pages)
Jun 16, 2026
b173d18
test: cover page_infos encodings and CLI formatters
Jun 16, 2026
963db75
test: add zero-dep end-to-end tests for mosaic CLI
Jun 16, 2026
d4c3a71
docs: add CLI page + parquet-cli comparison
Jun 18, 2026
9635042
docs: expand CLI page with meta example and parquet-cli design table
Jun 22, 2026
c76ed0a
feat(cli): add head, footer, column-size, dictionary commands
Jun 22, 2026
20716c6
feat(cli): add buckets command for mosaic bucket layout
Jun 22, 2026
0a64296
feat(cli): dictionary takes -c/--column to match parquet-cli
Jun 22, 2026
550d596
feat(cli): add --json to dictionary
Jun 22, 2026
04839b6
docs: document all 9 commands; remove parquet comparison
Jun 22, 2026
bb0a0fc
test: drop trivial encoding_names unit; assert footer/buckets --json
Jun 22, 2026
924ac4b
chore(cli): drop redundant gen.rs example
Jun 22, 2026
2091618
fix(cli): column-size counts monolithic buckets; bare Date32 JSON
Jun 22, 2026
35ab3d3
feat(cli): show compression ratio in column-size and buckets
Jun 23, 2026
e1de108
feat(cli): add count, cat --all and cat --where row filter
Jun 23, 2026
b9467e9
feat(cli): add convert (CSV import) and stats-based where pushdown
Jun 23, 2026
0218603
feat(cli): convert also imports JSON lines
Jun 23, 2026
02bc5d0
docs(cli): restructure README into Install/Inspect/Query/Convert sect…
Jun 23, 2026
311604a
fix(cli): harden page_infos bounds, where ordering, NaN JSON, convert…
Jun 23, 2026
af2d1b2
fix(cli): column-size omits total ratio when uncompressed size is par…
Jun 23, 2026
6a4356d
fix(cli): address review — valid JSON, type-driven where, exact paged…
Jun 23, 2026
08a4b84
refactor(cli): merge head into cat alias, fix Date pushdown, harden e…
Jun 23, 2026
ba2ff89
fix(cli): exact integer where/pushdown, ndjson returns Result
Jun 23, 2026
c4ba6f2
docs(cli): note where compares numbers exactly (=0.3 matches only sto…
Jun 23, 2026
2fd9ad0
chore(cli): use arrow umbrella crate instead of 5 split crates
Jun 23, 2026
c5c4762
fix(cli): convert pluralizes row/column count (no '1 rows')
Jun 23, 2026
950b2dc
fix(cli): --where works on a column excluded by -c
Jun 23, 2026
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

[workspace]
members = ["core", "ffi", "jni"]
members = ["core", "ffi", "jni", "cli"]
resolver = "2"

[profile.release]
36 changes: 36 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

[package]
name = "paimon-mosaic-cli"
version = "0.2.0"
edition = "2021"
description = "Mosaic file format — command line inspector (cat/meta/schema)"
license = "Apache-2.0"

[[bin]]
name = "mosaic"
path = "src/main.rs"

[dependencies]
paimon-mosaic-core = { path = "../core" }
arrow-array = "58"
arrow-schema = "58"
arrow-select = "58"
arrow-csv = "58"
arrow-json = "58"
clap = { version = "4", features = ["derive"] }
102 changes: 102 additions & 0 deletions cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

# mosaic CLI

A native command-line inspector for Mosaic files. It drives the read-only
`MosaicReader` API, so it needs no JVM and ships as a single binary. For C/C++
or Java callers, embed the format via the `ffi` (`mosaic.h`) or `jni` crates
rather than shelling out to this tool.

## Install

```bash
cargo run -p paimon-mosaic-cli -- <command> <file> # run from source
cargo install --path cli # install `mosaic`
mosaic <command> <file>
```

## Commands

Every command accepts `--json`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

convert does not accept --json, so this statement is currently inaccurate. Please scope this to the inspection/query commands or add a JSON mode to convert.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

convert does not accept --json, so this statement is currently inaccurate. Please scope this to the inspection/query commands or add a JSON mode to convert.

Fixed, scoped the statement to inspection/query commands; convert writes a file.


| Command | Shows | Reads |
|---------|-------|-------|
| `schema` | column names, Arrow types, nullability, bucket | footer only |
| `meta` | row groups, rows, per-column stats (null/min/max) | footer + index |
| `footer` | magic, version, buckets, compression | footer only |
| `buckets` | per-bucket layout, member columns, ratio | footer + index |
| `pages` | per-column encoding + on-disk slot size | bucket data |
| `dictionary` | dictionary entries of a dict column | bucket data |
| `column-size` | bytes per column + total compression ratio | footer + index |
| `cat` / `head` | rows as a table | column data |
| `count` | total row count | footer + index |
| `convert` | import CSV or JSON into a new file | writes file |

## Inspect

```text
$ mosaic schema data.mosaic
5 columns, 4 buckets
id: Int32 not null [bucket 0]
name: Utf8 [bucket 2]
kind: Utf8 [bucket 1]

$ mosaic buckets data.mosaic
row group 0:
bucket 0: monolithic 27B (uncompressed 59 B, 2.19x) [kind]
bucket 1: paged 373B [flag, id]

$ mosaic column-size data.mosaic
id: 349 B
kind: 28 B
total: 377 B (uncompressed 861 B, 2.28x)

$ mosaic pages data.mosaic
row group 0:
flag: bucket 0 encoding=const slot=16B
kind: bucket 1 encoding=dict slot=28B
```

## Query

`cat`/`head` take `-n <N>`, `--all`, `-c a,b` (projection) and
`--where "col op val"` (one condition: `=` `!=` `>` `>=` `<` `<=`).

```text
$ mosaic count data.mosaic
200

$ mosaic cat data.mosaic -n 2 --json
{"id":0,"name":"user_0","kind":"a","flag":7}
{"id":1,"name":"user_1","kind":"b","flag":7}

$ mosaic cat data.mosaic --all --where "id>100" -c id,kind
```

## Convert

Import CSV or JSON lines into a new Mosaic file; the schema is inferred.
`--stats id` builds min/max for those columns, which `cat --where` then uses to
skip row groups that cannot match.

```text
$ mosaic convert data.csv -o data.mosaic --stats id
wrote data.mosaic (200 rows, 5 columns)
```
Loading
Loading