noborus / trdsql

CLI tool that can execute SQL queries on CSV, LTSV, JSON, YAML and TBLN. Can output to various formats.
https://noborus.github.io/trdsql/
MIT License
1.94k stars 73 forks source link

`-ijq` does not work correctly from stdin #186

Closed ChristianCiach closed 2 years ago

ChristianCiach commented 2 years ago

Hi! Thanks for creating trdsql - it's awesome!

I just discovered this tool and I think it will on many occasions replace jq for me. But I think I've found a minor bug in the current version 0.9.1.

It's best shown using an example.

This works:

$ cat customer_basedata.json | trdsql -ijson 'SELECT id, name FROM -::.entities'

Also works:

$ trdsql -ijq '.entities' 'SELECT id, name FROM customer_basedata.json'

This doesn't work:

$ cat customer_basedata.json | trdsql -ijq '.entities' 'SELECT id, name FROM -'

Error message:

2022/04/22 14:17:01 import: too many columns on -::jq1

By the way, version 0.9.1 is missing on docker hub :)

noborus commented 2 years ago

The current version first requires the -ijson option.

cat customer_basedata.json | trdsql -ijson -ijq '.entities' 'SELECT id, name FROM -'

I can assume json when using the -ijq option, so I'll consider fixing it. Thank you very much.