|
| 1 | +## Pinot CLI |
| 2 | + |
| 3 | +An interactive and batch command-line client for Apache Pinot. It supports a rich interactive REPL, multiple output formats, history, pagination, configuration files, and batch execution. |
| 4 | + |
| 5 | +Features are modeled after the Trino CLI for familiarity and ergonomics. See the Trino CLI docs for reference: [Trino CLI documentation](https://trino.io/docs/current/client/cli.html). |
| 6 | + |
| 7 | +## Requirements |
| 8 | + |
| 9 | +- Java 11+ on PATH (Java 22+ recommended for performance) |
| 10 | + |
| 11 | +## Build |
| 12 | + |
| 13 | +From the repository root: |
| 14 | + |
| 15 | +```bash |
| 16 | +./mvnw -DskipTests -pl pinot-clients/pinot-cli -am package |
| 17 | +``` |
| 18 | + |
| 19 | +Artifacts: |
| 20 | + |
| 21 | +- `pinot-clients/pinot-cli/target/pinot-cli-*-executable.jar` (executable, recommended) |
| 22 | +- `pinot-clients/pinot-cli/target/pinot-cli-1.5.0-SNAPSHOT.jar` (thin) |
| 23 | + |
| 24 | +## Running |
| 25 | + |
| 26 | +### Interactive mode |
| 27 | + |
| 28 | +```bash |
| 29 | +pinot-clients/pinot-cli/target/pinot-cli-*-executable.jar \ |
| 30 | + -u jdbc:pinot://<controller-host>:<port> |
| 31 | +``` |
| 32 | + |
| 33 | +- Multi-line SQL is supported; end statements with `;` to execute. |
| 34 | +- Built-in commands: `help`, `clear`, `exit`, `quit`. |
| 35 | +- Default history file: `~/.pinot_history` (customize with `--history-file`). |
| 36 | +- Enable paging with a pager (e.g., `less`) via `--pager` or environment variables below. |
| 37 | + |
| 38 | +### Batch mode |
| 39 | + |
| 40 | +Execute a single statement: |
| 41 | + |
| 42 | +```bash |
| 43 | +pinot-clients/pinot-cli/target/pinot-cli-*-executable.jar \ |
| 44 | + -u jdbc:pinot://<controller-host>:<port> \ |
| 45 | + --output-format=CSV_HEADER \ |
| 46 | + --execute "SELECT * FROM myTable LIMIT 3;" |
| 47 | +``` |
| 48 | + |
| 49 | +Execute statements from a file: |
| 50 | + |
| 51 | +```bash |
| 52 | +pinot-clients/pinot-cli/target/pinot-cli-*-executable.jar \ |
| 53 | + -u jdbc:pinot://<controller-host>:<port> \ |
| 54 | + --output-format=JSON \ |
| 55 | + -f queries.sql |
| 56 | +``` |
| 57 | + |
| 58 | +## Options |
| 59 | + |
| 60 | +- `-u, --url` JDBC URL. Example: `jdbc:pinot://controller:9000` or `jdbc:pinotgrpc://controller:9000` (required) |
| 61 | +- `-n, --user` Username |
| 62 | +- `-p, --password` Password |
| 63 | +- `--header` Extra request header `key=value` (repeatable), e.g., `--header Authorization=Bearer <token>` |
| 64 | +- `--set` Query/session option `key=value` (repeatable). Forwarded as connection properties |
| 65 | +- `-e, --execute` Execute SQL and exit |
| 66 | +- `-f, --file` Execute SQL from file and exit |
| 67 | +- `-o, --output` Legacy: `table|csv|json` (backward compatibility). Prefer the formats below |
| 68 | +- `--output-format` Batch output format |
| 69 | +- `--output-format-interactive` Interactive output format (default: `ALIGNED`) |
| 70 | +- `--pager` Pager program used in interactive mode (e.g., `less -SRFXK`). Empty disables pagination |
| 71 | +- `--history-file` Path to history file for interactive mode (default: `~/.pinot_history`) |
| 72 | +- `--config` Path to a properties file with defaults (see Configuration below) |
| 73 | +- `--debug` Print stack traces and timing diagnostics to stderr |
| 74 | + |
| 75 | +### Output formats |
| 76 | + |
| 77 | +Available values for `--output-format` and `--output-format-interactive` (case-insensitive): |
| 78 | + |
| 79 | +- `CSV`, `CSV_HEADER`, `CSV_UNQUOTED`, `CSV_HEADER_UNQUOTED` |
| 80 | +- `TSV`, `TSV_HEADER` |
| 81 | +- `JSON` (one JSON object per line) |
| 82 | +- `ALIGNED` (ASCII table) |
| 83 | +- `VERTICAL` (record-oriented) |
| 84 | +- `AUTO` (chooses `ALIGNED` if it fits terminal width, otherwise `VERTICAL`) |
| 85 | +- `MARKDOWN` (Markdown table) |
| 86 | +- `NULL` (suppress normal results; useful for timing/error checks) |
| 87 | + |
| 88 | +## Configuration |
| 89 | + |
| 90 | +You can load defaults from a properties file using `--config` or via environment variables: |
| 91 | + |
| 92 | +- `PINOT_CONFIG` (preferred) |
| 93 | +- `TRINO_CONFIG` (supported for parity) |
| 94 | + |
| 95 | +Supported keys in the properties file (CLI flags take precedence): |
| 96 | + |
| 97 | +- `server` (maps to `--url`) |
| 98 | +- `user`, `password` |
| 99 | +- `output-format`, `output-format-interactive`, `output` |
| 100 | +- `pager`, `history-file`, `debug` |
| 101 | +- `headers.*` (e.g., `headers.Authorization=Bearer <token>`) -> becomes extra headers |
| 102 | +- Any other key is forwarded as a session option (equivalent to `--set key=value`) |
| 103 | + |
| 104 | +Example `pinot-cli.properties`: |
| 105 | + |
| 106 | +```properties |
| 107 | +server=jdbc:pinot://localhost:9000 |
| 108 | +user=alice |
| 109 | +output-format-interactive=AUTO |
| 110 | +pager=less -SRFXK |
| 111 | +history-file=/Users/alice/.pinot_history |
| 112 | +headers.Authorization=Bearer abc123 |
| 113 | +debug=true |
| 114 | +timeoutMs=60000 |
| 115 | +``` |
| 116 | + |
| 117 | +Run with: |
| 118 | + |
| 119 | +```bash |
| 120 | +PINOT_CONFIG=/path/to/pinot-cli.properties \ |
| 121 | +pinot-clients/pinot-cli/target/pinot-cli-*-executable.jar |
| 122 | +``` |
| 123 | + |
| 124 | +## Environment variables |
| 125 | + |
| 126 | +- `PINOT_CONFIG` / `TRINO_CONFIG`: path to a config properties file |
| 127 | +- `PINOT_PAGER` / `TRINO_PAGER`: pager command for interactive mode (e.g., `less -SRFXK`) |
| 128 | + |
| 129 | +## Examples |
| 130 | + |
| 131 | +Interactive with AUTO format and pager: |
| 132 | + |
| 133 | +```bash |
| 134 | +pinot-clients/pinot-cli/target/pinot-cli-*-executable.jar \ |
| 135 | + -u jdbc:pinot://localhost:9000 \ |
| 136 | + --output-format-interactive=AUTO \ |
| 137 | + --pager "less -SRFXK" |
| 138 | +``` |
| 139 | + |
| 140 | +Batch to JSON: |
| 141 | + |
| 142 | +```bash |
| 143 | +pinot-clients/pinot-cli/target/pinot-cli-*-executable.jar \ |
| 144 | + -u jdbc:pinot://localhost:9000 \ |
| 145 | + --output-format=JSON \ |
| 146 | + --execute "SELECT col1, col2 FROM myTable LIMIT 3;" |
| 147 | +``` |
| 148 | + |
| 149 | +## Notes |
| 150 | + |
| 151 | +- CLI arguments take precedence over config file values. |
| 152 | +- Pager is only used in interactive mode. Batch mode prints directly to stdout. |
| 153 | + |
| 154 | + |
0 commit comments