Skip to content

sql: implement EXISTS expressions#3291

Merged
petermattis merged 1 commit intomasterfrom
sql-subquery-alias-failure
Dec 9, 2015
Merged

sql: implement EXISTS expressions#3291
petermattis merged 1 commit intomasterfrom
sql-subquery-alias-failure

Conversation

@tamird
Copy link
Copy Markdown
Contributor

@tamird tamird commented Dec 2, 2015

Reduced version of #3288. Fails with:

--- FAIL: TestLogic (0.06s)
    logic_test.go:426: testdata/subquery:139: expected success, but found pq: qualified name "x.k" not found

Note this branch is on the main repo, not my fork (so you can push commits to it).

Review on Reviewable

@tamird tamird added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. SQL labels Dec 2, 2015
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't merge this if the test is failing. I'd change this to expect the error that is occurring and add a TODO comment to fix.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't planning on merging this; this branch is on the main repo so that someone (or I) can replace my commit with one that contains a fix.

@madelynnblue madelynnblue self-assigned this Dec 7, 2015
@madelynnblue
Copy link
Copy Markdown
Contributor

This can also be triggered by:

> select * from x where exists(select b from no_such_table);
query error: qualified name "x.b" not found

@tamird
Copy link
Copy Markdown
Contributor Author

tamird commented Dec 7, 2015

That error might be a red herring, since it is also produced by:

> select no_such_col from x;
query error: qualified name "x.no_such_col" not found

@madelynnblue
Copy link
Copy Markdown
Contributor

There is also:

> select * from x where exists(select a from no_such_table);
+---+
| a |
+---+
+---+

Where it successfully returns a result when a bogus table is specified.

Edit: the table x above was empty when I ran that query. When it has a row, the error changes to:

query error: sql/parser/eval.go:1049: unhandled type *parser.Subquery

@madelynnblue
Copy link
Copy Markdown
Contributor

I don't understand how it could be a red herring.

@tamird
Copy link
Copy Markdown
Contributor Author

tamird commented Dec 8, 2015

Assigning to @petermattis because I couldn't figure this out (and neither could @mjibson).

@tamird tamird assigned petermattis and unassigned madelynnblue Dec 8, 2015
@petermattis
Copy link
Copy Markdown
Collaborator

Ok, I'll take a look.

@petermattis petermattis force-pushed the sql-subquery-alias-failure branch from 8c78708 to ff4fc96 Compare December 9, 2015 19:39
@petermattis
Copy link
Copy Markdown
Collaborator

@mjibson @tamird PTAL

The error message was coming from scanNode.resolveQNames and was occurring because ExistsExpr.Walk was skipping over the Subquery node and walking the internal Subquery.Select.

@tamird
Copy link
Copy Markdown
Contributor Author

tamird commented Dec 9, 2015

LGTM. You can git commit --amend --reset-author to make yourself the author of this commit.

@tamird tamird changed the title sql: add failing test for aliased subquery sql: implement EXISTS expressions Dec 9, 2015
@petermattis petermattis force-pushed the sql-subquery-alias-failure branch from ff4fc96 to b613356 Compare December 9, 2015 19:52
@madelynnblue
Copy link
Copy Markdown
Contributor

LGTM


Review status: 0 of 6 files reviewed at latest revision, 4 unresolved discussions.


sql/parser/eval.go, line 878 [r2] (raw file):
handle -> handled


sql/parser/eval.go, line 1081 [r2] (raw file):
handle -> handled


sql/subquery.go, line 73 [r2] (raw file):
expression -> expressions
lease -> least


Comments from the review on Reviewable.io

@petermattis
Copy link
Copy Markdown
Collaborator

Good grief, I swear my grammar is better than what I demonstrated in this PR.


Review status: 0 of 6 files reviewed at latest revision, 4 unresolved discussions.


Comments from the review on Reviewable.io

@petermattis petermattis force-pushed the sql-subquery-alias-failure branch from b613356 to 75fe987 Compare December 9, 2015 20:27
petermattis added a commit that referenced this pull request Dec 9, 2015
@petermattis petermattis merged commit eaa3b75 into master Dec 9, 2015
@petermattis petermattis deleted the sql-subquery-alias-failure branch December 9, 2015 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants