Skip to content

CLI: Add REPL support to CLI#4465

Merged
MonkeyCanCode merged 6 commits into
apache:mainfrom
MonkeyCanCode:cli_repl
May 22, 2026
Merged

CLI: Add REPL support to CLI#4465
MonkeyCanCode merged 6 commits into
apache:mainfrom
MonkeyCanCode:cli_repl

Conversation

@MonkeyCanCode

Copy link
Copy Markdown
Contributor

This is second time where we got asked to support REPL (https://lists.apache.org/thread/mgfo0vyxjqb47bkp09d2gw8162f3n2kw). This PR adds the REPL support for Polaris CLI.

Sample outputs:

Start REPL session via host/port/client-id/client-secret:

➜  polaris git:(cli_repl) ./polaris --host localhost --port 8181 --client-id root --client-secret s3cr3t repl
Welcome to the Apache Polaris CLI REPL. Type 'help' for commands, 'exit' or Ctrl-D to quit.
Note: global auth flags (--host, --port, --profile, --client-id, --client-secret, ...) are bound at session start and ignored when re-specified inside the REPL.
polaris@localhost:8181>

Start REPL session via profile:

➜  polaris git:(cli_repl) ./polaris --profile dev repl
Welcome to the Apache Polaris CLI REPL. Type 'help' for commands, 'exit' or Ctrl-D to quit.
Note: global auth flags (--host, --port, --profile, --client-id, --client-secret, ...) are bound at session start and ignored when re-specified inside the REPL.
polaris@dev>

Top level help:

polaris@dev> help
Polaris commands:
 catalogs        manage catalogs
 principals      manage principals
 principal-roles manage principal roles
 catalog-roles   manage catalog roles
 privileges      manage privileges for a catalog role
 namespaces      manage namespaces
 profiles        manage profiles
 policies        manage policies
 setup           perform setup
 tables          manage tables
 find            find an identifier
 repl            start an interactive REPL session
REPL built-ins: exit, help, Ctrl-D

Use 'help <command>' or '<command --help>' for command details.

Help command on another command:

polaris@dev> help principals
usage: polaris principals [-h] [options] SUBCOMMAND ...

options:
  -h, --help            show this help message and exit

Subcommands:
  SUBCOMMAND
    create              Create a new principal
    delete              Delete a principal
    get                 Retrieve metadata for a principal
    list                List principals
    rotate-credentials  Rotate credentials for a principal
    update              Update properties of a principal
    access              Retrieve access details for a principal
    reset               Reset credentials for a principal
    summarize           Display a summary for a principal

Help option from command

polaris@dev> principals --help
usage: polaris principals [-h] [options] SUBCOMMAND ...

options:
  -h, --help            show this help message and exit

Subcommands:
  SUBCOMMAND
    create              Create a new principal
    delete              Delete a principal
    get                 Retrieve metadata for a principal
    list                List principals
    rotate-credentials  Rotate credentials for a principal
    update              Update properties of a principal
    access              Retrieve access details for a principal
    reset               Reset credentials for a principal
    summarize           Display a summary for a principal

Create a new principal:

polaris@dev> principals create test_principal
{"clientId": "3e6665fe17715085", "clientSecret": "57ad1ec91382cab04b73f23cd466b00a"}

List all principals:

polaris@dev> principals list
{"name": "root", "clientId": "root", "properties": {}, "createTimestamp": 1778964018874, "lastUpdateTimestamp": 1778964018874, "entityVersion": 1}
{"name": "test_principal", "clientId": "3e6665fe17715085", "properties": {}, "createTimestamp": 1778967344920, "lastUpdateTimestamp": 1778967344920, "entityVersion": 1}

Checklist

  • 🛡️ Don't disclose security issues! (contact security@apache.org)
  • 🔗 Clearly explained why the changes are needed, or linked related issues: Fixes #
  • 🧪 Added/updated tests with good coverage, or manually tested (and explained how)
  • 💡 Added comments for complex logic
  • 🧾 Updated CHANGELOG.md (if needed)
  • 📚 Updated documentation in site/content/in-dev/unreleased (if needed)

@dimas-b dimas-b left a comment

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.

LGTM 👍 Thanks, @MonkeyCanCode !

I tested it briefly... it works :) but it's a bit awkward .... for example create namespace requires a --catalog option. It would be nicer to be able to start repl --catalog polaris and not have to provide the catalog option inside the REPL 🙂

@flyrain flyrain left a comment

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.

Thanks for adding this, @MonkeyCanCode! It's pretty cool after trying. It's great that we don't have to re-typing credentials or profiles.

Overall, I think it is a good start point. It is a one-liner command now. We could add more context later, for example, adding a catalog as a context, as @dimas-b pointed out, similar to a typical sql repl, use catalog to set the current catalog, etc.

Comment thread client/python/apache_polaris/cli/constants.py Outdated
Comment thread client/python/apache_polaris/cli/constants.py Outdated
Comment thread client/python/apache_polaris/cli/command/repl.py Outdated
Comment thread client/python/apache_polaris/cli/command/repl.py Outdated
Comment thread site/content/in-dev/unreleased/command-line-interface.md Outdated
@MonkeyCanCode

Copy link
Copy Markdown
Contributor Author

LGTM 👍 Thanks, @MonkeyCanCode !

I tested it briefly... it works :) but it's a bit awkward .... for example create namespace requires a --catalog option. It would be nicer to be able to start repl --catalog polaris and not have to provide the catalog option inside the REPL 🙂

Good thinking and better UX as well. I will add this change soon.

@MonkeyCanCode

Copy link
Copy Markdown
Contributor Author

Thanks for the review and feed back @dimas-b and @flyrain . I will work on those changes later this week.

dimas-b
dimas-b previously approved these changes May 21, 2026

@dimas-b dimas-b left a comment

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.

I meant to approve in my previous review 😅

From my POV it's fine to merge this PR and improve later.

@github-project-automation github-project-automation Bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board May 21, 2026
@MonkeyCanCode

Copy link
Copy Markdown
Contributor Author

I meant to approve in my previous review 😅

From my POV it's fine to merge this PR and improve later.

All good. All feedbacks are addressed now. Do you mind take another look?

@MonkeyCanCode MonkeyCanCode requested a review from flyrain May 22, 2026 20:14
from typing import Optional
from cmd import Cmd

try:

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.

For the record, this is due to windows doesn't support readline (found this while play on my windows. ref: https://stackoverflow.com/questions/51157443/pythons-readline-module-not-available-for-windows). If we need to get this working on Windows, we can add pyreadline3 as suggested in the stackoverflow page as well. @flyrain @dimas-b

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.

I'm OK to add it later.

@flyrain flyrain left a comment

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.

+1. The feature is pretty cool. Thanks a lot for adding it, @MonkeyCanCode .

from typing import Optional
from cmd import Cmd

try:

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.

I'm OK to add it later.

@MonkeyCanCode MonkeyCanCode merged commit 872d6b8 into apache:main May 22, 2026
24 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to merge to Done in Basic Kanban Board May 22, 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.

3 participants