Skip to content

Conversation

@andref5
Copy link

@andref5 andref5 commented Sep 5, 2025

Add table-format=<true|false> Argument to cbt sql Command

This PR introduces a new optional argument table-format=<true|false> to the cbt sql command.

Purpose
The table-format flag allows users to control the formatting of the SQL output:

When table-format=true (default), the output is displayed in a human-readable table format.
When table-format=false, the output is printed in raw format, making it easier to redirect to a file and use SQL functions to format or process the data programmatically.
Use Case
This enhancement is particularly useful for scripting and automation scenarios where the output of cbt sql needs to be piped or saved to a file for further processing. For example:

cbt sql 'SELECT FORMAT("%s,%s,%s",
                    SAFE_CONVERT_BYTES_TO_STRING(cell_data["os_build"]),
                    SAFE_CONVERT_BYTES_TO_STRING(cell_data["os_name"]),
                    SAFE_CONVERT_BYTES_TO_STRING(cell_data["os_version"])
                ) AS osBuild_osName_osVersion
        FROM mobile-time-series' table-format=false

osBuild_osName_osVersion
SQ1A.220105.002,android,Android12
SQ1A.220105.001,android,Android12
SQ1A.220105.007,android,Android12
SD1A.210817.019.C4,android,Android12
SQ1A.220105.002,android,Android12

Additional Changes
The cbtdoc.go file was also updated using go generate to reflect the new argument in the documentation.

@andref5 andref5 requested review from a team and igorbernstein2 as code owners September 5, 2025 14:15
@google-cla
Copy link

google-cla bot commented Sep 5, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@andref5 andref5 force-pushed the feat/sql-table-format-arg branch from a4acbca to 710be90 Compare September 5, 2025 14:23
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.

1 participant