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.93k stars 72 forks source link

Ignores nullable columns #269

Closed avoidik closed 4 months ago

avoidik commented 4 months ago

Hello,

Great tool, I was exploring some data, and stumbled upon an issue, when optional columns have been dropped, here is a basic repro case:

$ echo -e '{"method": "GET"}\n{"method": "POST", "meta.user": "with.dot"}' | trdsql "SELECT * FROM -"
"{""method"": ""GET""}"
"{""method"": ""POST"""

is this something expected?

noborus commented 4 months ago

yes. If the number of columns is not constant, you need to specify the number of rows to pre-read. It is recommended to specify it as follows.

echo -e '{"method": "GET"}\n{"method": "POST", "meta.user": "with.dot"}' |trdsql -ir 2 "SELECT * FROM -"
"{""method"": ""GET""}",
"{""method"": ""POST"""," ""meta.user"": ""with.dot""}"
avoidik commented 4 months ago

Thanks, that's it!