Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nbk2000 opened this issue Sep 24, 2022 · 8 comments
Open

Comments

@nbk2000
Copy link

nbk2000 commented Sep 24, 2022

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

@cube2222
Copy link
Owner

@nbk2000 could you try wrapping it in back ticks?

SELECT * FROM `example.com.json`

@nbk2000
Copy link
Author

nbk2000 commented Sep 25, 2022

That results in the same error

@cube2222
Copy link
Owner

@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?

@nbk2000
Copy link
Author

nbk2000 commented Sep 25, 2022

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?

@cube2222
Copy link
Owner

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\`"

@nbk2000
Copy link
Author

nbk2000 commented Sep 25, 2022

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)

@cube2222
Copy link
Owner

cube2222 commented Sep 25, 2022

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 cube2222 changed the title Parsing error when opening json file with two periods in filename Allow using multiple dots in file names without wrapping in backticks. Sep 25, 2022
@amotl
Copy link

amotl commented Apr 12, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants