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 --bins columnq-cli

Usage

One off query

The sql subcommand executes a provided SQL query against specificed static dataset and returns 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.4.0-py3-none-win_amd64.whl (16.2 MB view details)

Uploaded Python 3 Windows x86-64

columnq_cli-0.4.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (17.0 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

columnq_cli-0.4.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (16.0 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

columnq_cli-0.4.0-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (17.2 MB view details)

Uploaded Python 3 manylinux: glibc 2.12+ x86-64

columnq_cli-0.4.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (32.2 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.4.0-py3-none-macosx_10_7_x86_64.whl (16.8 MB view details)

Uploaded Python 3 macOS 10.7+ x86-64

File details

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

File metadata

File hashes

Hashes for columnq_cli-0.4.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 39d1e982fa2ac5cb4649d05f67cc18d61d65dabd27e8053ecc9ef488a03e6a9a
MD5 005d607c77937729ffe7ac3bc103081a
BLAKE2b-256 f3de1b3f07dce4ff390f9cee077d2d93bfb809d8e077792c9f4afa4d314409d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for columnq_cli-0.4.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 384caf8a23a5e88e8dfd30b6b1c09ec081f0484893382076a278509d13412374
MD5 5785bb5ae19682bb79c9d5677a6de4d5
BLAKE2b-256 75d10afe2b1ff03652898fe864f690ee9b76f70a1226fd3a95360e5e73358a69

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for columnq_cli-0.4.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b7aa58b95802801518fcaaece0c533cc93e796c828fdf5f851d05d9d75b8ecf8
MD5 eb8e8bccdf5d072a9637f4d51230f54a
BLAKE2b-256 1c7e10eede3a772062d0207ffdac903ebf36ba9fc0e7593aa377043e6988a25d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for columnq_cli-0.4.0-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 2053056ee06db4c6dff3b81bb6b52fda35b0862c7703dff139033dcb64fe3cb3
MD5 cccaa736c67e58420adf276c66e612e1
BLAKE2b-256 102e1438bfba1a97995fdc5d4fb6bd279d94c2c5b1301c9a9f2dadd6e1bfad02

See more details on using hashes here.

File details

Details for the file columnq_cli-0.4.0-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.4.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 8d0850b94f93a8d1f6b912c42904be1f7a52719c960eb1f430d09796bf064b72
MD5 430977f5db22993ba150508044e8b154
BLAKE2b-256 d6f82c1c3720f36da2bf6191a33805ea8766e64d0fd1745b62973532e5aa5a1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for columnq_cli-0.4.0-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 7760cc723152a328d49b5284a0e0eab44934e288ad0a05b368e9511640a3f1f5
MD5 f16261395493ff0396e6d2173b762633
BLAKE2b-256 b0d4880aae93c7cd5f41b2a8affb91ce770754f1244bc11f4ac0fb629ecff09d

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