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

opt: allow qualified star without FROM clause #46233

Merged
merged 1 commit into from
Mar 18, 2020

Conversation

RaduBerinde
Copy link
Member

We incorrectly error out if we have a qualified star without a FROM clause; the
star can refer to an outer table. We also incorrectly take the columns from the
input scope which is not necessarily the scope that the star is referring to.

Unfortunately, in the specific case in #45855 (SELECT (SELECT t.*)) we don't
get the nice column name x like in postgres; we get ?column?. This is
because in our code the aliases are determined before building the expressions;
this seems complicated to change.

Fixes #45855.

Release note (bug fix): queries with qualified stars that refer to tables
in outer scopes now work.

Release justification: low risk changes to existing functionality.

@RaduBerinde RaduBerinde requested a review from rytaft March 18, 2020 04:13
@RaduBerinde RaduBerinde requested a review from a team as a code owner March 18, 2020 04:13
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained

We incorrectly error out if we have a qualified star without a FROM clause; the
star can refer to an outer table. We also incorrectly take the columns from the
input scope which is not necessarily the scope that the star is referring to.

Unfortunately, in the specific case in cockroachdb#45855 (`SELECT (SELECT t.*)`) we don't
get the nice column name `x` like in postgres; we get `?column?`. This is
because in our code the aliases are determined before building the expressions;
this seems complicated to change.

Fixes cockroachdb#45855.

Release note (bug fix): queries with qualified stars that refer to tables
in outer scopes now work.

Release justification: low risk changes to existing functionality.
@RaduBerinde
Copy link
Member Author

bors r+

@craig
Copy link
Contributor

craig bot commented Mar 18, 2020

Build succeeded

@craig craig bot merged commit a16d8aa into cockroachdb:master Mar 18, 2020
@RaduBerinde RaduBerinde deleted the outer-star branch March 18, 2020 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sql: Outer "star" reference to table results in error
3 participants