Skip to content

[python] Add a table vector-search CLI command - #10163

Open
jackylee-ch wants to merge 1 commit into
apache:masterfrom
jackylee-ch:python-cli-vector-search
Open

jackylee-ch wants to merge 1 commit into
apache:masterfrom
jackylee-ch:python-cli-vector-search

Conversation

@jackylee-ch

Copy link
Copy Markdown
Contributor

Purpose

The pypaimon CLI already exposes table full-text-search, but there is no equivalent for vector search even though the vector search API (Table.new_vector_search_builder()) is fully implemented. To run a nearest-neighbor query from the command line users currently have to fall back to writing Python.

This adds a table vector-search command that mirrors full-text-search: it takes the vector column (--column), a query vector (--query, given as comma-separated floats or a JSON-style array), an optional result limit (--limit, default 10), column selection (--select) and output format (--format table|json), runs the search locally and prints the matching rows.

Tests

pypaimon/tests/cli_table_test.py: added unit tests for the query-vector parser (comma / JSON array / whitespace / empty / non-numeric) and CLI tests for the error paths (invalid vector, unknown column, unknown table).

API and Format

No public API or format change; new CLI subcommand only, no default changed.

Documentation

Consistent with the existing full-text-search CLI command; --help lists the new command and its options.

df = read.to_pandas(splits)

output_format = getattr(args, 'format', 'table')
if output_format == '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.

 --format json  is not usable with the default vector-search projection. Arrow list/vector columns become  numpy.ndarray  values in pandas, and json.dumps(df.to_dict(...))  raises  TypeError: Object of type ndarray is not JSON serializable . Since the searched vector column is included by default, this is the normal JSON path rather than an edge case. Please serialize from Arrow/Python-native values (for example  to_pylist() ) or normalize NumPy arrays/scalars before calling json.dumps, and add a successful JSON-output test that includes the embedding column.

Validation: Direct parser probes passed. I reproduced both the ranking loss ( bitmap_order=[2,10] ,  score_order=[10,2] ) and the vector JSON  ndarray  failure. The catalog-backed CLI tests cannot initialize locally because of the repository’s Windows URI issue ( Unrecognized filesystem type in URI: c ). GitHub’s failing Python jobs are unrelated and all report the existing interval_partition_test.py SimpleNamespace.path_factory  error.

@jackylee-ch
jackylee-ch force-pushed the python-cli-vector-search branch from 61fd23f to 6d07fb7 Compare September 25, 2026 01:23
The pypaimon CLI exposes `table full-text-search` but has no equivalent
for vector search, even though the vector search API
(`new_vector_search_builder`) is already available. Users who want to run
a nearest-neighbor query from the command line have to fall back to
writing Python.

Add a `table vector-search` command that mirrors `full-text-search`: it
takes the vector column, a query vector (comma-separated floats or a
JSON-style array), an optional result limit, column selection and output
format, runs the search locally and prints the matching rows.
@jackylee-ch
jackylee-ch force-pushed the python-cli-vector-search branch from 6d07fb7 to 9ebd735 Compare September 25, 2026 02:32
@jackylee-ch

Copy link
Copy Markdown
Contributor Author

Thanks @Akash3121.

JSON: fixed — added _records_for_json to convert the numpy arrays pandas produces for the embedding column into native lists before json.dumps, plus a unit test serializing an ndarray embedding column.

Ranking: execute_local() returns a RoaringBitmap64, so rows come back in row-id order and the read path exposes no per-row scores for the CLI to re-sort — a read-layer property shared by all consumers. I'd rather fix ordering in the scan layer (emit ScoredGlobalIndexResult by score) as a follow-up than sort in the CLI. Does that split sound right?

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.

2 participants