mihaibudiu commented on code in PR #5193:
URL: https://github.com/apache/calcite/pull/5193#discussion_r3815426348
##########
core/src/main/codegen/templates/Parser.jj:
##########
@@ -2516,9 +2516,7 @@ SqlNode TableRef3(ExprContext exprContext, boolean
lateral) :
// Standard SQL (and Postgres) allow applying "AS alias" to a JOIN,
// e.g. "FROM (a CROSS JOIN b) AS c". The new alias obscures the
// internal aliases, and columns cannot be referenced if they are
- // 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.
Review Comment:
I would suggest removing the last sentence. It works, fine, we don't know
when it was introduced.
##########
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java:
##########
@@ -2864,11 +2864,17 @@ private SqlNode registerFrom(
expr = call.operand(0);
final boolean needAliasNamespace = call.operandCount() > 2
|| expr.getKind() == SqlKind.VALUES || expr.getKind() ==
SqlKind.UNNEST
- || expr.getKind() == SqlKind.COLLECTION_TABLE;
+ || expr.getKind() == SqlKind.COLLECTION_TABLE
+ || expr.getKind() == SqlKind.JOIN;
+ // 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 =
Review Comment:
this is subtle, but the tests pass, so I hope it's right
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]