[
https://issues.apache.org/jira/browse/CASSANDRA-19985?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18099360#comment-18099360
]
Arvind Kandpal commented on CASSANDRA-19985:
--------------------------------------------
Hi [~bschoeni] ,
Thank you so much for the detailed review and the provided reference code! I
have implemented the parallel {{_json_formatters}} registry exactly as you
suggested to ensure native Python objects are returned for JSON serialization.
I have also updated {{test_cqlsh_output.py}} and added the new
{{test_json_formatting.py}} unit tests to thoroughly verify the type
correctness for {{{}null{}}}, {{{}bigint{}}}, collections, and fallback types.
To ensure everything is rock-solid, I ran exhaustive end-to-end and unit
testing (with some assistance from Claude 3.5 Sonnet). Here is the quick
summary of the successful test run:
* *Build:* {{ant build}} passed successfully.
* *Unit & Integration Tests:* 76/76 tests passed (including the 34 new unit
tests for JSON formatting).
* *Live E2E Verification:*
** {{bigintcol}} / {{{}varintcol{}}}: Renders as native integers (e.g.,
{{{}"bytes_in": 14413{}}}) instead of strings.
** {{{}null{}}}: Renders correctly as JSON {{{}null{}}}.
** {{map}} / {{list}} / {{{}set{}}}: Properly serialized as JSON objects and
arrays.
** {{tabular}} and {{csv}} modes: Verified completely untouched and working as
expected.
The changes have been pushed to the PR. Please let me know if there's anything
else needed here!
> Enhance CQLSH to support machine-readable output formatting
> -----------------------------------------------------------
>
> Key: CASSANDRA-19985
> URL: https://issues.apache.org/jira/browse/CASSANDRA-19985
> Project: Apache Cassandra
> Issue Type: New Feature
> Components: CQL/Interpreter
> Reporter: Brad Schoening
> Assignee: Arvind Kandpal
> Priority: Normal
> Attachments: json_formatters_example.py, test_json_formatting.py
>
> Time Spent: 1.5h
> Remaining Estimate: 0h
>
> Existing CQLSH output formatting provides tabular formatting using grid-like
> separators and text alignment which is designed for user readability.
> When CQL is run for non-interactive tasks as part of a pipeline this
> formatting complicates the machine processing of the output. As an example,
> [Sqlite|https://www.sqlite.org/cli.html] has a command line flag -mode to
> switch between tablular, csv, and several other supported formats.
> This enhancement will provide a new mode argument which will initially offer
> tabular and csv output formats. Tabular will remain the default so there will
> be no change for existing users. In the future, other modes such as json and
> insert could be added.
> {noformat}
> --mode={tabular, csv}
> Specify an output display format. The default is tabular.
> {noformat}
> The existing Copy To can be used for exporting to CSV, but it doesn't allow
> for query criteria and thus isn't a general solution for this issue.
> In cqlshmain.py, the EXPAND CQLSH option which uses print_formatted_result()
> for result output is an example of alternative formatting.
> Paging will have to be properly managed. A good formatter should handle a
> stream of rows rather than requiring the entire list in memory, especially
> for large SELECT * queries.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]