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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file columnq_cli-0.2.1-py3-none-win_amd64.whl
.
File metadata
- Download URL: columnq_cli-0.2.1-py3-none-win_amd64.whl
- Upload date:
- Size: 11.4 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4747fc0de042d2f37248975bf2d3034ceab9fced4d80649dd762fef9837cabe1 |
|
MD5 | 9a324d8550208cbfb75e5b1ccd84f5e1 |
|
BLAKE2b-256 | 3a1e2431bb53e7d6fc7ea88f1cfd89380c25d29c9f00350a1d8d92aa25b22151 |
File details
Details for the file columnq_cli-0.2.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
.
File metadata
- Download URL: columnq_cli-0.2.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 12.7 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3fb12f9c84cf7243e87786aaf43c5045bf457e71799896135dc0fdd4d09ea96 |
|
MD5 | 443dad3749a7f78e205087ba11f1e5bc |
|
BLAKE2b-256 | e28f3edcd653542410c0a1a5c81ad45770d0d4773e17ad8b40d915edabf657cd |
File details
Details for the file columnq_cli-0.2.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: columnq_cli-0.2.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 11.3 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 472f51269568ff893350b91eb884910f36c6a06f81d9f4dd2ff2a5795f0e6e01 |
|
MD5 | a4197f75899a1ae9e30770647195b00f |
|
BLAKE2b-256 | 37f1bcc39f58322807a0078e90f9b6f44816c515e5cbf0973e465c2d320c43e9 |
File details
Details for the file columnq_cli-0.2.1-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
.
File metadata
- Download URL: columnq_cli-0.2.1-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
- Upload date:
- Size: 12.2 MB
- Tags: Python 3, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91ac604c02111679162847a5fb74862749d5c7d58f77a03316ba4f3cd799bca1 |
|
MD5 | 66b4028cb0857642fdec6d5366f648b7 |
|
BLAKE2b-256 | 790eecf320eeb09bc4551ca30c6e5b40c83e33744de3a8e56b7c26b1425cffc1 |
File details
Details for the file columnq_cli-0.2.1-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
.
File metadata
- Download URL: columnq_cli-0.2.1-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
- Upload date:
- Size: 22.5 MB
- Tags: Python 3, macOS 10.9+ universal2 (ARM64, x86-64), macOS 10.9+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d42c2b54c04da56a9ee0dbbf6d550a3a8ff178dba6e39dda2fe38e5d89fc4bd0 |
|
MD5 | fd7f9a1c35952a002890fe30346da4c1 |
|
BLAKE2b-256 | c3f06b3ee712358de5a96b94cb34f3f09e10d10887234b254df39333e3bdacb1 |
File details
Details for the file columnq_cli-0.2.1-py3-none-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: columnq_cli-0.2.1-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.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bae0423295af33ac6f5b0bb848eb2d2de4bcc0e35a50e60bc9fcf5383867b5eb |
|
MD5 | 60b576b9e41955ee1cd4495aa30fb57d |
|
BLAKE2b-256 | 42ba289a3fa924934923cc4ed9e77fceb92ade8baf792b3f9dd25afaecaa3b09 |