Subquery join rewrite produces wrong SQL in some cases

Description

I just found an edge case where the current implementation of the subquery rewrite produces wrong results. The problem occurs when a non-related join alias is used in the ON clause with a key restriction. Something like

currently produces SQL like

The subquery uses a join alias that is only available outside of it. The fix is to prevent inlining such columns. A PR is on it's way...

Environment

None

Status

Assignee

Christian Beikov

Reporter

Christian Beikov

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure