-
Notifications
You must be signed in to change notification settings - Fork 9
[cli] Add mosaic command-line tool #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jianguotian
wants to merge
27
commits into
apache:main
Choose a base branch
from
jianguotian:feat/mosaic-cli
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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)
b173d18
test: cover page_infos encodings and CLI formatters
963db75
test: add zero-dep end-to-end tests for mosaic CLI
d4c3a71
docs: add CLI page + parquet-cli comparison
9635042
docs: expand CLI page with meta example and parquet-cli design table
c76ed0a
feat(cli): add head, footer, column-size, dictionary commands
20716c6
feat(cli): add buckets command for mosaic bucket layout
0a64296
feat(cli): dictionary takes -c/--column to match parquet-cli
550d596
feat(cli): add --json to dictionary
04839b6
docs: document all 9 commands; remove parquet comparison
bb0a0fc
test: drop trivial encoding_names unit; assert footer/buckets --json
924ac4b
chore(cli): drop redundant gen.rs example
2091618
fix(cli): column-size counts monolithic buckets; bare Date32 JSON
35ab3d3
feat(cli): show compression ratio in column-size and buckets
e1de108
feat(cli): add count, cat --all and cat --where row filter
b9467e9
feat(cli): add convert (CSV import) and stats-based where pushdown
0218603
feat(cli): convert also imports JSON lines
02bc5d0
docs(cli): restructure README into Install/Inspect/Query/Convert sect…
311604a
fix(cli): harden page_infos bounds, where ordering, NaN JSON, convert…
af2d1b2
fix(cli): column-size omits total ratio when uncompressed size is par…
6a4356d
fix(cli): address review — valid JSON, type-driven where, exact paged…
08a4b84
refactor(cli): merge head into cat alias, fix Date pushdown, harden e…
ba2ff89
fix(cli): exact integer where/pushdown, ndjson returns Result
c4ba6f2
docs(cli): note where compares numbers exactly (=0.3 matches only sto…
2fd9ad0
chore(cli): use arrow umbrella crate instead of 5 split crates
c5c4762
fix(cli): convert pluralizes row/column count (no '1 rows')
950b2dc
fix(cli): --where works on a column excluded by -c
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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`. | ||
|
|
||
| | 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) | ||
| ``` | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
convertdoes not accept--json, so this statement is currently inaccurate. Please scope this to the inspection/query commands or add a JSON mode toconvert.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, scoped the statement to inspection/query commands;
convertwrites a file.