KazukiKandaKK opened a new pull request, #19610:
URL: https://github.com/apache/pinot/pull/19610

   ### What
   `PostQueryCommand` (the `pinot-admin.sh PostQuery` CLI) only ever logged the 
raw JSON broker response, with no way to render results as CSV or write them to 
a file. This addresses the first two TODO items in #6939:
   
   - [ ] user can specify the response format, e.g. CSV
   - [ ] user can specify a file to dump the query response to
   
   The third item (output compression) is left out of scope for this PR, 
consistent with how the earlier (unmerged) attempt at this issue (#7096) scoped 
its own follow-up. Note `pinot-cli` already supports CSV/TSV output; this PR 
targets the older `pinot-admin` `PostQuery` command that #6939 names explicitly 
and that still only supports raw JSON.
   
   ### Changes
   - Added `-outputFormat` (`JSON` default, or `CSV`) and `-outputFile` CLI 
options.
   - CSV rendering uses `resultTable` (`dataSchema.columnNames` + `rows`) via 
`commons-csv` (already a transitive dependency through `pinot-csv`, which 
`pinot-tools` already depends on). `commons-csv` correctly quotes cell values 
containing commas, unlike the ad hoc `Joiner`-based approach in the earlier PR 
#7096 attempt.
   - `formatResponse()` never throws for a CSV-incompatible response: it falls 
back to the raw response if the response isn't valid JSON at all (e.g. a 
proxy/broker error page), or has no `resultTable` (e.g. the query errored out) 
— so error detail is never silently dropped.
   - If `resultTable` is present alongside a non-empty `exceptions` list or a 
partial result, CSV mode still renders the table but logs a warning that the 
CSV won't reflect that detail (recommending `-outputFormat JSON` for full 
inspection).
   - Omitting both options keeps the pre-existing behavior unchanged (log the 
raw JSON response, no file write).
   - Added `PostQueryCommandTest` with 9 cases covering the default JSON 
passthrough, CSV rendering (including comma-containing cell values), the 
`resultTable`-absent fallback, the not-valid-JSON fallback, the 
`resultTable`+`exceptions` case, CLI argument parsing for both formats, and 
`execute()`'s output-file writing (with/without `-outputFile` set).
   
   ### Out of scope
   - Output compression (item 3 of #6939) and remote (S3) / directory 
destinations — left for a follow-up, same scoping decision as #7096.
   - No changes to the broker query API or Quickstart; #7096's own discussion 
concluded the broker-API route adds wire-compat surface for limited gain, and 
this PR follows that conclusion.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to