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

Use of DoubleQuotes not working for some table names #36

Closed dboeke closed 1 year ago

dboeke commented 1 year ago

Describe the bug Can't query column header for csv file with the name "Billable Hours"

Steampipe version (steampipe -v) Example: v0.16.3

Plugin version (steampipe plugin list) Example: v0.3.2

To reproduce create this csv file:

Billable Hours,Bundle Type
10,xxx

query the file:

> select "Billable Hours" from test
Error: column "Billable Hours" does not exist (SQLSTATE 42703)
> select "Bundle Type" from test
+-------------+
| Bundle Type |
+-------------+
| xxx         |
+-------------+

Expected behavior Both queries should work

Additional context Was having trouble reproducing with other column names, e.g. "Foo Bar" works fine...

e-gineer commented 1 year ago

hmmm .... wondering how you got to that state?

What do you see for .inspect test?

Seems to work for me:

/tmp/crap $ cat test.csv 
Billable Hours,Bundle Type
10,xxx
/tmp/crap $ steampipe query
Welcome to Steampipe v0.17.0-alpha.16
For more information, type .help
> .inspect test
+----------------+-------+-------------------------------------------------------+
| column         | type  | description                                           |
+----------------+-------+-------------------------------------------------------+
| Billable Hours | text  | Field 0.                                              |
| Bundle Type    | text  | Field 1.                                              |
| _ctx           | jsonb | Steampipe context in JSON form, e.g. connection_name. |
+----------------+-------+-------------------------------------------------------+
> select "Billable Hours" from test;
+----------------+
| Billable Hours |
+----------------+
| 10             |
+----------------+

Time: 73ms.
> 
dboeke commented 1 year ago

Strange

> .inspect test
+-------------------+-------+-------------------------------------------------------+
| column            | type  | description                                           |
+-------------------+-------+-------------------------------------------------------+
| Bundle Type       | text  | Field 1.                                              |
| _ctx              | jsonb | Steampipe context in JSON form, e.g. connection_name. |
| Billable Hours    | text  | Field 0.                                              |
+-------------------+-------+-------------------------------------------------------+
> select "Billable Hours" from test
Error: column "Billable Hours" does not exist (SQLSTATE 42703)
> select "Bundle Type" from test
+-------------+
| Bundle Type |
+-------------+
| xxx         |
+-------------+
>
daeho-ro commented 1 year ago

@dboeke It seems that there exist a hidden character. Because the column should given alphabetical order when you inspect the table, but it does not.

e-gineer commented 1 year ago

oh - good catch @daeho-ro ... I wonder if it's a UTF-8 CSV file, similar to https://github.com/turbot/steampipe-plugin-csv/issues/38?

daeho-ro commented 1 year ago

I think this is same as #38.