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: fix implicit lateral for SRFs when using JOIN syntax #71396

Merged
merged 1 commit into from
Oct 12, 2021

Conversation

RaduBerinde
Copy link
Member

When SRFs are used as a table, they imply that the join is lateral.
This works for the multiple table syntax, but not for the JOIN syntax.
This commit addresses this omission.

Fixes #70342.

Release note (bug fix): Fixes an incorrect "no data source matches
prefix" error for queries that use a set-returning function on the
right-hand side of a JOIN (unless LATERAL is explicitly
specified).

@RaduBerinde RaduBerinde requested a review from a team as a code owner October 11, 2021 13:43
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@mgartner mgartner left a comment

Choose a reason for hiding this comment

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

:lgtm_strong:

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @rytaft)

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: Good find!

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! 2 of 0 LGTMs obtained (waiting on @RaduBerinde)


pkg/sql/opt/optbuilder/join.go, line 44 at r1 (raw file):

	// the left side.
	if t, ok := join.Right.(*tree.AliasedTableExpr); ok && t.Lateral {
		telemetry.Inc(sqltelemetry.LateralJoinUseCounter)

do we still need this telemetry?

Copy link
Member Author

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @mgartner and @rytaft)


pkg/sql/opt/optbuilder/join.go, line 44 at r1 (raw file):

Previously, rytaft (Rebecca Taft) wrote…

do we still need this telemetry?

Yeah, I removed it accidentally (and some tests failed on CI because of it). Moved it to exprIsLateral.

When SRFs are used as a table, they imply that the join is lateral.
This works for the multiple table syntax, but not for the JOIN syntax.
This commit addresses this omission.

Fixes cockroachdb#70342.

Release note (bug fix): Fixes an incorrect "no data source matches
prefix" error for queries that use a set-returning function on the
right-hand side of a `JOIN` (unless `LATERAL` is explicitly
specified).
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.

Reviewed 1 of 2 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @RaduBerinde)

@RaduBerinde
Copy link
Member Author

bors r+

@craig
Copy link
Contributor

craig bot commented Oct 12, 2021

Build succeeded:

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 this pull request may close these issues.

sql: CTE source not available as function argument in JOIN target
4 participants