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

confusing error when running wrong SQL that uses a snippet #902

Closed
edublancas opened this issue Sep 29, 2023 · 0 comments · Fixed by #912
Closed

confusing error when running wrong SQL that uses a snippet #902

edublancas opened this issue Sep 29, 2023 · 0 comments · Fixed by #912
Assignees

Comments

@edublancas
Copy link

When running a SQL query that depends on a snippet and there's an error, the error message is misleading

Notebook:

%load_ext sql
%sql duckdb://

Connecting to 'duckdb://'

%%sql
create table penguins as
select * from 'https://raw.githubusercontent.com/mwaskom/seaborn-data/master/penguins.csv'

Running query in 'duckdb://'

Count
%%sql --save mysnippet
select * from penguins

Running query in 'duckdb://'

species island bill_length_mm bill_depth_mm flipper_length_mm body_mass_g sex
Adelie Torgersen 39.1 18.7 181 3750 MALE
Adelie Torgersen 39.5 17.4 186 3800 FEMALE
Adelie Torgersen 40.3 18.0 195 3250 FEMALE
Adelie Torgersen None None None None None
Adelie Torgersen 36.7 19.3 193 3450 FEMALE
Adelie Torgersen 39.3 20.6 190 3650 MALE
Adelie Torgersen 38.9 17.8 181 3625 FEMALE
Adelie Torgersen 39.2 19.6 195 4675 MALE
Adelie Torgersen 34.1 18.1 193 3475 None
Adelie Torgersen 42.0 20.2 190 4250 None
Truncated to displaylimit of 10.

This will complain with:

There is no table with name 'mysnippet'.
Did you mean: 'mysnippet'

But that should not apapear because the actual reason is that the function not_a_function doesn't exist.

%%sql
select not_a_function(body_mass_g) from mysnippet

Generating CTE with stored snippets: 'mysnippet'

Running query in 'duckdb://'

TableNotFoundError: If using snippets, you may pass the --with argument explicitly.
For more details please refer: https://jupysql.ploomber.io/en/latest/compose.html#with-argument

There is no table with name 'mysnippet'.
Did you mean: 'mysnippet'


Original error message from DB driver:
(duckdb.CatalogException) Catalog Error: Scalar Function with name not_a_function does not exist!
Did you mean "tan"?
LINE 3: se...
               ^
[SQL: WITH mysnippet AS (
select * from penguins)
select not_a_function(body_mass_g) from mysnippet]
(Background on this error at: https://sqlalche.me/e/20/f405)

If you need help solving this issue, send us a message: https://ploomber.io/community
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.

2 participants