turbot / steampipe-plugin-csv

Use SQL to instantly query data from CSV files. Open source CLI. No DB required.
https://hub.steampipe.io/plugins/turbot/csv
Apache License 2.0
19 stars 4 forks source link

Outputting results from query as CSV into current working directory results in error #33

Closed dboeke closed 1 year ago

dboeke commented 2 years ago

Describe the bug When using Steampipe to perform a query using the csv plugin and outputting the result of that query as csv into the current working directory results in an error

Steampipe version (steampipe -v) v0.16.0

Plugin version (steampipe plugin list) csv: v0.3.0

To reproduce

Welcome to Steampipe v0.16.0
For more information, type .help
> .inspect test
+---------+-------+-------------------------------------------------------+
| column  | type  | description                                           |
+---------+-------+-------------------------------------------------------+
| _ctx    | jsonb | Steampipe context in JSON form, e.g. connection_name. |
| column1 | text  | Field 0.                                              |
| column2 | text  | Field 1.                                              |
+---------+-------+-------------------------------------------------------+
> .exit
➜  mod_list steampipe query "select * from test;" --output csv >> results.csv
Warning: executeQueries: query 1 of 1 failed: ERROR: failed to start plugin 'hub.steampipe.io/plugins/turbot/csv@latest': runtime error: invalid memory address or nil pointer dereference (SQLSTATE HV000)
➜  mod_list steampipe query "select * from test;" --output csv >> results.test
Warning: executeQueries: query 1 of 1 failed: ERROR: failed to start plugin 'hub.steampipe.io/plugins/turbot/csv@latest': runtime error: invalid memory address or nil pointer dereference (SQLSTATE HV000)
➜  mod_list rm results.csv
➜  mod_list steampipe query "select * from test;" --output csv >> results.test
➜  mod_list cat results.test
column1,column2,_ctx
value1,value2,"{""connection_name"":""csv""}"
value3,value4,"{""connection_name"":""csv""}"
➜  mod_list

Expected behavior No error, or warning not to do it.

Additional context error persists until the csv is deleted from the directory.

cbruno10 commented 2 years ago

Hey @dboeke , I just tried to reproduce this error but was unable to using csv v0.3.2 and Steampipe v0.17.0-alpha.9:

cbruno@M1P csv % cat ~/csv/a.csv
a,b,c,grant
1,2,3,g1
4,5,6,g2
7,8,9,g3
8,8,9,g4
9,8,9,g5
10,8,9,g6
11,8,9,g7
12,8,9,g8
cbruno@M1P csv % steampipe query "select * from a"
+----+---+---+-------+---------------------------+
| a  | b | c | grant | _ctx                      |
+----+---+---+-------+---------------------------+
| 9  | 8 | 9 | g5    | {"connection_name":"csv"} |
| 12 | 8 | 9 | g8    | {"connection_name":"csv"} |
| 10 | 8 | 9 | g6    | {"connection_name":"csv"} |
| 11 | 8 | 9 | g7    | {"connection_name":"csv"} |
| 8  | 8 | 9 | g4    | {"connection_name":"csv"} |
| 1  | 2 | 3 | g1    | {"connection_name":"csv"} |
| 4  | 5 | 6 | g2    | {"connection_name":"csv"} |
| 7  | 8 | 9 | g3    | {"connection_name":"csv"} |
+----+---+---+-------+---------------------------+
cbruno@M1P csv % steampipe query "select * from a" --output csv
a,b,c,grant,_ctx
4,5,6,g2,"{""connection_name"":""csv""}"
12,8,9,g8,"{""connection_name"":""csv""}"
11,8,9,g7,"{""connection_name"":""csv""}"
1,2,3,g1,"{""connection_name"":""csv""}"
10,8,9,g6,"{""connection_name"":""csv""}"
7,8,9,g3,"{""connection_name"":""csv""}"
8,8,9,g4,"{""connection_name"":""csv""}"
9,8,9,g5,"{""connection_name"":""csv""}"
cbruno@M1P csv % steampipe query "select * from a" --output csv >> test.csv
cbruno@M1P csv % cat test.csv
a,b,c,grant,_ctx
8,8,9,g4,"{""connection_name"":""csv""}"
10,8,9,g6,"{""connection_name"":""csv""}"
9,8,9,g5,"{""connection_name"":""csv""}"
12,8,9,g8,"{""connection_name"":""csv""}"
7,8,9,g3,"{""connection_name"":""csv""}"
4,5,6,g2,"{""connection_name"":""csv""}"
1,2,3,g1,"{""connection_name"":""csv""}"
11,8,9,g7,"{""connection_name"":""csv""}"
github-actions[bot] commented 1 year ago

'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.'

github-actions[bot] commented 1 year ago

'This issue was closed because it has been stalled for 90 days with no activity.'