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

%sql produces an error with a leading space and - #958

Closed
maciejb opened this issue Dec 8, 2023 · 1 comment · Fixed by #964
Closed

%sql produces an error with a leading space and - #958

maciejb opened this issue Dec 8, 2023 · 1 comment · Fixed by #964
Assignees

Comments

@maciejb
Copy link

maciejb commented Dec 8, 2023

What happens?

When a space precedes -, as in a numerical operation like something * -1 , jupysql incorrectly parses the - to indicate a switch operator.

I presume this is the same root issue as #918, but this particular edge case was not addressed in #938

image

To Reproduce

Run:

%sql select 5 * -1;

OS:

Any

JupySQL Version:

0.10.4

Full Name:

Maciej Bukczynski

Affiliation:

Darkhorse Analytics

@edublancas
Copy link

hi @maciejb, thanks for reporting this. we improved the SQL parsing in 0.10.4 but I just confirmed the edge case you're reporting. as a temporary workaround, you can remove the trailing ;

(jupysql) eduardo@macbookair dev/jupysql » ipython
Python 3.10.12 (main, Jul  5 2023, 15:02:25) [Clang 14.0.6 ]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.17.2 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import sql; sql.__version__
Out[1]: '0.10.4'

In [2]: %load_ext sql
<IPython.core.display.HTML object>

In [3]: %sql duckdb://
Connecting to 'duckdb://'

In [4]: %sql select 5 * -1;
UsageError: unrecognized arguments: -1;

In [5]: %sql select 5 * -1
Running query in 'duckdb://'
Out[5]:
+----------+
| (5 * -1) |
+----------+
|    -5    |
+----------+

In [6]:

@bryannho this is another edge case of the PR you recently worked on. seems like an easy fix so please tackle it

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

Successfully merging a pull request may close this issue.

3 participants