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: Error messages should be improved in case of no matching data source #22966

Closed
rytaft opened this issue Feb 22, 2018 · 3 comments
Closed
Assignees
Labels
A-sql-name-resolution SQL name resolution rules and CTEs. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)

Comments

@rytaft
Copy link
Collaborator

rytaft commented Feb 22, 2018

Consider the following invalid query:

root@:26257/> select count(tpch.nation.n_nationkey) from tpch.customer c, tpch.public.nation n where tpch.public.customer.c_nationkey = nation.n_nationkey group by tpch.public.nation.n_nationkey limit 10;

The error that CockroachDB returns for this query is:

pq: no data source matches prefix: tpch.public.customer

PostgreSQL has a friendlier error message with a hint:

Postgres: ERROR: invalid reference to FROM-clause entry for table "nation" Hint: Perhaps you meant to reference the table alias "n". Position: 14
@rytaft rytaft changed the title Error messages should be improved in case of no matching data source sql: Error messages should be improved in case of no matching data source Feb 22, 2018
@knz
Copy link
Contributor

knz commented Feb 24, 2018

I'll look what I can do. Note that I never like pg's error message that refers to a "FROM" clause, because it can also appear when there is no FROM clause whatsoever.

Meanwhile I'll just ignore pg's hint for now, since it's complex to implement we're not going to keep the current lookup code anyway.

But Becca I do have a hint for you: the object pgerror.Error has a SetHint method. I encourage you to implement any hint you'd like in the lookup code you recently implemented.

@knz knz added this to the Later milestone Feb 24, 2018
@rytaft
Copy link
Collaborator Author

rytaft commented Feb 24, 2018

Sounds good - thanks!

@rytaft rytaft mentioned this issue Feb 26, 2018
@knz knz added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) A-sql-name-resolution SQL name resolution rules and CTEs. labels Apr 24, 2018
@petermattis petermattis removed this from the Later milestone Oct 5, 2018
@knz
Copy link
Contributor

knz commented Oct 23, 2018

Fixed in #27396.

@knz knz closed this as completed Oct 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-name-resolution SQL name resolution rules and CTEs. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
Projects
None yet
Development

No branches or pull requests

3 participants