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.3.0-py3-none-win_amd64.whl (13.3 MB view details)

Uploaded Python 3 Windows x86-64

columnq_cli-0.3.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (14.1 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

columnq_cli-0.3.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (13.1 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

columnq_cli-0.3.0-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (14.2 MB view details)

Uploaded Python 3 manylinux: glibc 2.12+ x86-64

columnq_cli-0.3.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (26.4 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.3.0-py3-none-macosx_10_7_x86_64.whl (13.7 MB view details)

Uploaded Python 3 macOS 10.7+ x86-64

File details

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

File metadata

File hashes

Hashes for columnq_cli-0.3.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 51c4417853e18df2651013020f90e9c2450be7b5c438678f0c4ba0fe80b0c433
MD5 a6ab5b0a3aba250726cdc52091d74006
BLAKE2b-256 ce9d2c0e0595a5ab72d1b421565fa5808aa5caaa59793bd50d5be55508d51640

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for columnq_cli-0.3.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 895b62990d43330d0f10f419330e140ad39ec1087e73997cde14c5fed415fc15
MD5 9b33b96de7468357e4464cfa6e7b3db8
BLAKE2b-256 eaf709f54977ad6dbad9dcef8ef3553bc49bf2df865394da83d12a373655d908

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for columnq_cli-0.3.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 906f1f97060c1e17810b1710645f0f27e7ca9b06f5c016e7b8c9285ba90cc110
MD5 a141005f0517543bf780c09beb7f594e
BLAKE2b-256 82cb662be2c48a4db10cc304b66794d67c1fb668ea86090dd88d197b1f268ba5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for columnq_cli-0.3.0-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 5a42e2d938c09d7d11589c43bf9836c67b5314144e270698c16028feaea3e325
MD5 363b48661b0465db02f8573f45572bb4
BLAKE2b-256 85f8583b4b1702d12407beead34f4a6ce927f299f617a7b8ad929efc308d459f

See more details on using hashes here.

File details

Details for the file columnq_cli-0.3.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.3.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 762f6b03bfbbee54df82f05a9f47afad2cb5c1628180d1c7ed8eec6c4548fd03
MD5 ab0fcfce2ebd6d489b31c88b64e947bf
BLAKE2b-256 26c7ad4d521656917c3bd5cfc5f967389551e8f0d46344ff637ffcc7a7255048

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for columnq_cli-0.3.0-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 0efd97c4d32ce099f2628bcfe750685d5bc7f6393336d2fd10b4a16eba8469e7
MD5 dd74ae8b97b5d80c4197b3e560012e5c
BLAKE2b-256 002b57cecb1de077e8a587f880139a77db84c4f0dd24007454493589e2ebce08

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