Repository navigation
[Feature] Add snapshot index and file key range inspection to PyPaimon CLI - #11701
ViktorBystrov72 wants to merge 3 commits into
Conversation
| with patch.object(TableIndexesTable, '_build_arrow_table', return_value=rows): | ||
| result = json.loads(self._run_table_command_success( | ||
| 'indexes', identifier, '--snapshot-id', '1', '--limit', '1', '-f', 'json' | ||
| )) |
There was a problem hiding this comment.
Nit: Because TableIndexesTable._build_arrow_table is patched with synthetic column names (row_range_start / row_range_end instead of TableIndexesTable's actual global_index_row_range_start / global_index_row_range_end) and ignores self, this test doesn't verify that TableIndexesTable actually reads from the view pinned to --snapshot-id 1, nor does it cover the empty-result branch (No indexes found for table ...).
There was a problem hiding this comment.
I replaced the mocked Arrow table with a real Avro index manifest and two snapshots. The CLI reads and limits the historical snapshot while the latest snapshot returns an empty result. The fixture also checks the snapshot ID and preserves large row ranges and nulls. On this base the system-table columns are named row_range_start and row_range_end. The 10 focused tests passed. Updated test
| import pandas as pd | ||
| display_id = _snapshot_display_value(snapshot_id) | ||
| values = [[display_id, *(_snapshot_display_value(value) for value in row.values())] for row in rows] | ||
| print(pd.DataFrame(values, columns=['snapshot_id'] + batch.column_names).to_string(index=False)) |
There was a problem hiding this comment.
Nit: Right above in cmd_table_list_files (lines 652–654), snapshot_id is included in each row dictionary (rows = [dict(snapshot_id=snapshot_id, **dict(zip(columns, values))) ...]) as well as at the top level of the JSON payload, whereas here snapshot_id is only prepended in --format table and omitted from each row in --format json. Not a blocker (having snapshot_id only once at the top level in JSON is arguably cleaner, matching list-manifests), just noting the slight difference across the system-table-backed CLI commands.
There was a problem hiding this comment.
I kept snapshot_id at the top level in JSON because all rows come from the same pinned snapshot, matching the list-manifests layout. Table output includes it as the first column. The real-manifest fixture now checks both formats and the empty snapshot.
Purpose
Refs #11697.
Add read-only
paimon table indexesandpaimon table file-key-rangescommands over the existing PyPaimon system tables. Both pin the requested or latest snapshot, report its ID, and support--limit, table output, and JSON output.JSON preserves null values and integer metadata. The display limit applies after reading the system table. The
file-indexescommand requires a new reader and can be handled separately.Tests
The two targeted
CliTableTestcases passed on Python 3.13. They cover a retained snapshot, the latest snapshot ID in table output, missing snapshots, and limited output with nulls and large integers.