octosql icon indicating copy to clipboard operation
octosql copied to clipboard

Allow using multiple dots in file names without wrapping in backticks.

Open nbk2000 opened this issue 3 years ago • 8 comments

Using octosql version 0.9.4 and running the following command:

octosql "SELECT * FROM example.com.json"

Results in the following error:

Error: couldn't parse query: invalid argument syntax error at position 27

If the filename is changed to example_com.json then no error occurs and the program functions normally

nbk2000 avatar Sep 24 '22 19:09 nbk2000

@nbk2000 could you try wrapping it in back ticks?

SELECT * FROM `example.com.json`

cube2222 avatar Sep 24 '22 22:09 cube2222

That results in the same error

nbk2000 avatar Sep 25 '22 03:09 nbk2000

@nbk2000 can't reproduce, I've just tried

octosql "SELECT * FROM `books.test.json`"

and it works perfectly well.

Is it possible that a different part of your query is resulting in that error?

cube2222 avatar Sep 25 '22 10:09 cube2222

I don't think so, since changing the filename results in correct behavior, and the error message is quite explicit as to the position of the offending character. For example:

octosql "SELECT * FROM `example.com.json`"

results in the error:

Error: couldn't parse query: invalid argument syntax error at position 15

While removing the backticks like this:

octosql "SELECT * FROM example.com.json"

results in the error:

Error: couldn't parse query: invalid argument syntax error at position 27

This is on Ubuntu AMD64, in case that makes any difference.

Out of curiosity, What happens on your system when you don't include the back ticks?

nbk2000 avatar Sep 25 '22 15:09 nbk2000

Ok, this actually seems to be caused by bash. I've been running on the fish shell, but on bash I get the same error as you and the first line of the output is

bash: example.com.json: command not found

so it seems like bash is treating the backticked part like a command it should execute and use the output of.

Escaping it seems to work correctly:

octosql "SELECT * FROM \`example.com.json\`"

cube2222 avatar Sep 25 '22 16:09 cube2222

Yep backticks cause execution in bash. My results are the same as yours, so this is a workable workaround.

Can I make a feature request that multi dot files be supported without resorting to escaped backticks? (seems like an unnecessary footgun)

nbk2000 avatar Sep 25 '22 16:09 nbk2000

Sure, agreed, I'll look into it when I have some time. Until then, I'll change the title of this issue to track this.

cube2222 avatar Sep 25 '22 17:09 cube2222

Hi there,

Escaping it seems to work correctly. Yep backticks cause execution in bash. My results are the same as yours, so this is a workable workaround.

I was struggling on the same thing and wanted to add that using single quotes is another option.

octosql 'SELECT * FROM `foo-bar.csv`;'

With kind regards, Andreas.

P.S.: By the way, thanks so much for conceiving octosql, @cube2222.

amotl avatar Apr 12 '23 20:04 amotl