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

Partial Case-Sensivity makes CAMELCase.csv fail #20

Closed pniederlag closed 2 years ago

pniederlag commented 2 years ago

Describe the bug I have a CAMELCase.csv file on a case-sensivtive file-system

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

Plugin version (steampipe plugin list) csv@latest | 0.3.0 | csv

To reproduce

create a simple .csv file with some UPPERlower.csv name

.inspect does work, however using select always bails with relation does not exist

> .inspect csv.FIxme
+--------+-------+-------------------------------------------------------+
| column | type  | description                                           |
+--------+-------+-------------------------------------------------------+
| _ctx   | jsonb | Steampipe context in JSON form, e.g. connection_name. |
| one    | text  | Field 0.                                              |
| two    | text  | Field 1.                                              |
+--------+-------+-------------------------------------------------------+
> select * from FIxme
Error: relation "fixme" does not exist (SQLSTATE 42P01)

Expected behavior the query should work

Additional context

renaming the file to alllowercase.csv works

e-gineer commented 2 years ago

Hey @pniederlag ... Postgres requires mixed case identifiers to be quoted.

So, can you please try select * from "FIxme" ... that should work as you expect. Same is true for column names, etc.

Our docs should be clearer on this though - we should add mixed case examples at:

cbruno10 commented 2 years ago

@pniederlag - To add onto what @e-gineer mentioned, from Postgres' doc on Lexical Structure:

Quoting an identifier also makes it case-sensitive, whereas unquoted names are always folded to lower case. For example, the identifiers FOO, foo, and "foo" are considered the same by PostgreSQL, but "Foo" and "FOO" are different from these three and each other.

We'll look into improving the examples in the README and index doc though as this is not always apparent.

pniederlag commented 2 years ago

@e-gineer how come I didn't even try this myself? Big thx for your instant feedback. Of course you are right.. quoting "FIxme" as well as "FIeldname" does the trick quite right.

thx for your efforts on clearifying docs

pniederlag commented 2 years ago

from my point of view this ticket could be closed

cbruno10 commented 2 years ago

Thanks @pniederlag for confirming the quotes work! We're tracking the doc updates in https://github.com/turbot/steampipe-plugin-csv/issues/21, so if you have anymore questions or feedback, please feel free to comment in that issue as well.