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

Uploaded Python 3 Windows x86-64

columnq_cli-0.2.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (12.7 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

columnq_cli-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (11.3 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

columnq_cli-0.2.0-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (12.2 MB view details)

Uploaded Python 3 manylinux: glibc 2.12+ x86-64

columnq_cli-0.2.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (22.3 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.0-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.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: columnq_cli-0.2.0-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.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

File hashes

Hashes for columnq_cli-0.2.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 e0a911a194eb7d7898e94b3aa5abb288ff51bcdf86036301304decc0eba4143f
MD5 55bb81b51191e924e69bfef44592c7bb
BLAKE2b-256 c75c2b22748292bbc96341527e600b627f42cd58ec846589151c98eae6829859

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for columnq_cli-0.2.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 0be9f23386dac384d9e7ba7d88c079cb4aeeca1e9eb693e26fd8a23351c41797
MD5 f48bce59d36dfffd8746dba7af8a793b
BLAKE2b-256 801e91dcc90bffa8a3a7d3854ab296960fbe3df95dc3f0d3ade084a399ee51fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for columnq_cli-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3f18ae7cc13dcd4528dcfd03f6dc1c21527ff32a1edb8152e52c64b61607f7e8
MD5 8a98dededfb3de01de64bb958a14e55f
BLAKE2b-256 7856bacb093b9e4e705c4c112e4e51af140e8e0ba9e35ad5ef75f867c812acd5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for columnq_cli-0.2.0-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 d72a1568c4585cf8fad544950c70c54fa25edfeab725043c4af8a3f0de5c28bf
MD5 67ecd59e6f4c653e3557a12c855251d3
BLAKE2b-256 c499792bfd40ec95bca59d034110aa1402056f0dc60dd10726ff5335c4315d01

See more details on using hashes here.

File details

Details for the file columnq_cli-0.2.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.2.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 e67a1522afb2642bfe19d3f78052d1235669e5003f205d9ef66ab6b742070f98
MD5 324b548916eefa65cdf26daf9f900fe9
BLAKE2b-256 66aadfdd8c17483fd27df88663a6ec699eac534142048330239a4829a97e03c1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: columnq_cli-0.2.0-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.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

File hashes

Hashes for columnq_cli-0.2.0-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 b478ef178738f3b8eb324a3027df61138ce84c8c2a2edf83067ed3f1346d04c7
MD5 f033490e7ec7577e2c1b53adf5894b44
BLAKE2b-256 7931d6186319723683c468a62d66c4abfbbb3bfa6de42bda93ad752b7450051c

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