Skip to main content

No project description provided

Project description

Columnq

Simple CLI to help you query tabular data with support for a rich set of growing formats and data sources.

It supports JSON, CSV, Parquet, Arrow and all other formats that are supported by ROAPI, which is documented at here.

It also supports querying datasets from remote locations like S3 and HTTPs, see ROAPI's blob store documentation for more info.

Installation

Pre-built binary

The pre-built binaries hosted on GitHub releases. These binaries are self-contained so you can just drop them into your PATH.

The same set of binaries are also distributed through PyPI:

pip install columnq-cli

Build from source

cargo install --locked --git https://github.com/roapi/roapi --branch main --bin columnq-cli

Usage

One off query

The sql sbucommand execute a provided SQL query against specificed static dataset and return the result in stdout on exit. This is usually useful for script automation tasks.

$ columnq sql --table test_data/spacex_launches.json \
  "SELECT COUNT(id), DATE_TRUNC('year', CAST(date_utc AS TIMESTAMP)) as d FROM spacex_launches WHERE success = true GROUP BY d ORDER BY d DESC"
+-----------+---------------------+
| COUNT(id) | d                   |
+-----------+---------------------+
| 4         | 2021-01-01 00:00:00 |
| 26        | 2020-01-01 00:00:00 |
| 13        | 2019-01-01 00:00:00 |
| 21        | 2018-01-01 00:00:00 |
| 18        | 2017-01-01 00:00:00 |
| 8         | 2016-01-01 00:00:00 |
| 6         | 2015-01-01 00:00:00 |
| 6         | 2014-01-01 00:00:00 |
| 3         | 2013-01-01 00:00:00 |
| 2         | 2012-01-01 00:00:00 |
| 2         | 2010-01-01 00:00:00 |
| 1         | 2009-01-01 00:00:00 |
| 1         | 2008-01-01 00:00:00 |
+-----------+---------------------+

By default, the sql subcommand outputs results in human friendly table format. You can change the output format using --output option to make it more friendly for automations.

$ columnq sql --table test_data/spacex_launches.json --output json "SELECT COUNT(id) AS total_launches FROM spacex_launches"
[{"total_launches":132}]

Automate with UNIX pipes

Just like other UNIX tools, columnq supports consuming data stream from stdin to integrate with other CLI tools using UNIX pipe:

find . -printf "%M|%n|%u|%s|%P\n" | columnq sql \
    --table 't=stdin,format=csv,has_header=false,delimiter=|' \
    "SELECT SUM(column_4) as total_size FROM t"
+------------+
| total_size |
+------------+
| 9875017987 |
+------------+

Format conversion

The Columnq CLI can also be used as a handy utility to convert tabular data between various formats: json, parquet, csv, yaml, arrow, etc.

$ columnq sql --table 't=test_data/uk_cities_with_headers.csv' 'SELECT * FROM t' --output json
$ cat test_data/blogs.parquet | columnq sql --table 't=stdin,format=parquet' 'SELECT * FROM t' --output json

Interactive console

For dataset exploration, you can use the console subcommand to query multiple datasets in an interactive console environment:

$ columnq console \
    --table "uk_cities=test_data/uk_cities_with_headers.csv" \
    --table "test_data/spacex_launches.json"
columnq(sql)> SELECT * FROM uk_cities WHERE lat > 57;
+-----------------------------+-----------+-----------+
| city                        | lat       | lng       |
+-----------------------------+-----------+-----------+
| Elgin, Scotland, the UK     | 57.653484 | -3.335724 |
| Aberdeen, Aberdeen City, UK | 57.149651 | -2.099075 |
| Inverness, the UK           | 57.477772 | -4.224721 |
+-----------------------------+-----------+-----------+
columnq(sql)> SELECT COUNT(*) FROM spacex_launches WHERE success=true AND upcoming=false;
+-----------------+
| COUNT(UInt8(1)) |
+-----------------+
| 111             |
+-----------------+

Explore in memory catalog and table schemas:

columnq(sql)> SHOW TABLES;
+---------------+--------------------+-----------------+------------+
| table_catalog | table_schema       | table_name      | table_type |
+---------------+--------------------+-----------------+------------+
| datafusion    | public             | uk_cities       | BASE TABLE |
| datafusion    | public             | spacex_launches | BASE TABLE |
| datafusion    | information_schema | tables          | VIEW       |
| datafusion    | information_schema | columns         | VIEW       |
+---------------+--------------------+-----------------+------------+
columnq(sql)> SHOW COLUMNS FROM uk_cities;
+---------------+--------------+------------+-------------+-----------+-------------+
| table_catalog | table_schema | table_name | column_name | data_type | is_nullable |
+---------------+--------------+------------+-------------+-----------+-------------+
| datafusion    | public       | uk_cities  | city        | Utf8      | NO          |
| datafusion    | public       | uk_cities  | lat         | Float64   | NO          |
| datafusion    | public       | uk_cities  | lng         | Float64   | NO          |
+---------------+--------------+------------+-------------+-----------+-------------+

Development

Debug mode

Set the RUST_LOG environment variable to info,columnq=debug to run columnq in verbose debug logging.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

columnq_cli-0.2.2-py3-none-win_amd64.whl (11.3 MB view details)

Uploaded Python 3 Windows x86-64

columnq_cli-0.2.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (12.9 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

columnq_cli-0.2.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (11.5 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

columnq_cli-0.2.2-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (12.4 MB view details)

Uploaded Python 3 manylinux: glibc 2.12+ x86-64

columnq_cli-0.2.2-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (22.5 MB view details)

Uploaded Python 3 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

columnq_cli-0.2.2-py3-none-macosx_10_7_x86_64.whl (11.8 MB view details)

Uploaded Python 3 macOS 10.7+ x86-64

File details

Details for the file columnq_cli-0.2.2-py3-none-win_amd64.whl.

File metadata

  • Download URL: columnq_cli-0.2.2-py3-none-win_amd64.whl
  • Upload date:
  • Size: 11.3 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for columnq_cli-0.2.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 71c501e5f913571f04c6671ee9b8e7e0b7b7ba2e0dad7fce48a9c35491865b28
MD5 9eaee54788a33e4eae4b5461d1e8bf51
BLAKE2b-256 ec5077eba553ec8c84b81b213dbbfcefbdf74fbfca56256ab3b20cc41be0723a

See more details on using hashes here.

File details

Details for the file columnq_cli-0.2.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for columnq_cli-0.2.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 4fdb1fcd482d873649568e61c872ede0dc4cdbb0368e463e835207000ea926f0
MD5 f1d296797e65070ad14b24e94b0a1337
BLAKE2b-256 05ab72eedf86c487d5f662d3efb7ea21daa30fa88012fca0f70a40b3831d552a

See more details on using hashes here.

File details

Details for the file columnq_cli-0.2.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for columnq_cli-0.2.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 099167a08d1e2467b8411a37953f126e631ddd6120b3172465572772534bab7c
MD5 85d0acb97055ad48f6c7800828adca79
BLAKE2b-256 da0737101931f87f87841373862b7451a5d3d4fef736e41104746f23425f2a99

See more details on using hashes here.

File details

Details for the file columnq_cli-0.2.2-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for columnq_cli-0.2.2-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 a1cf0d7a5760353827a00b336747fc5bed709d02ae42cf951a5f0bc0ab94cac2
MD5 079e195f6216b67cbf13bfff9ec4c0b8
BLAKE2b-256 4e835f4d30966201d956913916826ae7a689471c92af0a3272f156823636a5f1

See more details on using hashes here.

File details

Details for the file columnq_cli-0.2.2-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for columnq_cli-0.2.2-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 0b7404867b5c46a03287b74e70292701635d2aecd0e4ad13e3c0495ed0efcc2f
MD5 bbcbaeab154d5ca5559fc4d17e5fcc4e
BLAKE2b-256 b9731c8fc18b64ac95f3fb9e7435627483c52e5d456bd16dbc9becdae8cef6da

See more details on using hashes here.

File details

Details for the file columnq_cli-0.2.2-py3-none-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: columnq_cli-0.2.2-py3-none-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 11.8 MB
  • Tags: Python 3, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for columnq_cli-0.2.2-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 4c4ff8dc83c1ae0d4705b56fefc6dad68ced9fb2f23d9f5c9487aea67b1b0ff0
MD5 d7d78b15e39feb8e939d3c099562a594
BLAKE2b-256 81efa40b076ca60b1416d9504289ce4628859be834a39ce0d698798edcf36cab

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page