Skip to content

Trailing comma output misleading error message #9949

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

Closed
alexandreyc opened this issue Apr 4, 2024 · 3 comments · Fixed by #11453
Closed

Trailing comma output misleading error message #9949

alexandreyc opened this issue Apr 4, 2024 · 3 comments · Fixed by #11453
Labels
bug Something isn't working

Comments

@alexandreyc
Copy link

alexandreyc commented Apr 4, 2024

Describe the bug

Putting a trailing comma after the last column/expression within a select statement produces a misleading error message.

To Reproduce

When running the following:

create table my_table as (
    select 'Alice' as name, 42 as age
    union all
    select 'Bob' as name, 1337 as age
);

select
    name,
    age,
from
    my_table

We got the following error message:

Schema error: No field named name.

Expected behavior

Either:

  • Accepting trailing comma
  • Have an informative error message

Additional context

It took me a while to figure out the issue so I though that it might be helpful to improve on this.

@alexandreyc alexandreyc added the bug Something isn't working label Apr 4, 2024
@alexandreyc alexandreyc changed the title Trailing comma output wrong error message Trailing comma output misleading error message Apr 4, 2024
@jonahgao
Copy link
Member

jonahgao commented Apr 5, 2024

In this case, sqlparser-rs interprets from as a column name, and my_table is recognized as the alias of the from column. Not sure whether we need to solve this problem in sqlparser-rs or in DataFusion. In some databases, from as a keyword cannot be used as a column name.

@alamb
Copy link
Contributor

alamb commented Apr 26, 2024

Thanks Looks lik

looks like there is a PR upstream to fix this: apache/datafusion-sqlparser-rs#1212 - I'll try and review it shortly

@MohamedAbdeen21
Copy link
Contributor

Thanks for the issue @alexandreyc.

apache/datafusion-sqlparser-rs#1212 is merged.

The new error message is:

Error during parsing: ParserError("Expected an expression, found: from at Line: 11, Column 5")

However, it will be several weeks till it arrives to DF, since we'll have to wait for the new release of sqlparser, sqlparser version upgrade in DF, and then the new release of DF.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants