mithrandie / csvq

SQL-like query language for csv
https://mithrandie.github.io/csvq
MIT License
1.51k stars 63 forks source link

Support fully qualified file names in CREATE TABLE and INSERT commands #108

Open KayKursawe opened 1 year ago

KayKursawe commented 1 year ago

In SELECT statements, i can specify a fully qualified file to be queried, e. g. SELECT a, b, c FROM file:/foo/bar

However, in CREATE TABLE and INSERT statements (and probably a few others) this doesn't work. Instead, all that seems to work is to specifiy the filename without the leading path and without the trailing file extension as a table name: CREATE TABLE foo(a, b, c)

How about providing the file: notation consistently to all statements?

kpym commented 1 year ago

Have you tried enclosing the filename in backticks?

SELECT a, b, c FROM `/foo/bar`
KayKursawe commented 1 year ago

SELECT is not an issue, fully qualified paths are working. I'm talking about CREATE TABLE and INSERT statements.

Since SELECT a, b, c FROM file:/foo/bar.csv is working using the file: notation, I'd be happy to use that in any other statement, too, like this: CREATE TABLE file:/foo/bar.csv(a, b, c) INSERT INTO file:/foo/bar.csv(a, b, c) VALUES (1, 2, 3)

Atm, this is the only way it works: CREATE TABLE foo(a, b, c) INSERT INTO foo(a, b, c) VALUES (1, 2, 3)

mithrandie commented 1 year ago

The file specification in URL format is intended to be read-only. Therefore, it can currently be used only in SELECT queries. However, it is true that specifying local files in URL format is useful when creating or updating files. I'll consider supporting it.