Skip to content

[CALCITE-5168] Allow AS after parenthesized JOIN - #5193

Open
xuzifu666 wants to merge 1 commit into
apache:mainfrom
xuzifu666:calcite-5168
Open

[CALCITE-5168] Allow AS after parenthesized JOIN#5193
xuzifu666 wants to merge 1 commit into
apache:mainfrom
xuzifu666:calcite-5168

Conversation

@xuzifu666

Copy link
Copy Markdown
Member

!ok

# [CALCITE-5168] Allow AS after parenthesized JOIN
select d.dname, j.empno, j.ename

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This sql programe was validated in postgresql: https://onecompiler.com/postgresql/44ypqwt2u

// not unique. TODO: Support this behavior; see
// [CALCITE-5168] Allow AS after parenthesized JOIN
checkNotJoin(tableRef);
// not unique. See [CALCITE-5168] Allow AS after parenthesized JOIN.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would suggest removing the last sentence. It works, fine, we don't know when it was introduced.

@xuzifu666 xuzifu666 Aug 20, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You are right, it is not need to introduce, I had removed it.

// For an aliased join, the join's children must not be visible outside
// the alias. Prevent JoinScope.addChild from propagating children to
// the using scope by using parentScope.
final SqlValidatorScope exprUsingScope =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is subtle, but the tests pass, so I hope it's right

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks, agreed this is subtle. The intent is to prevent the children of an aliased join from leaking into the outer scope; the new validator tests cover that emp/bonus are no longer visible once the join is aliased as x.

@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants