[
https://issues.apache.org/jira/browse/FLINK-7854?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16210804#comment-16210804
]
ASF GitHub Bot commented on FLINK-7854:
---------------------------------------
Github user xccui commented on a diff in the pull request:
https://github.com/apache/flink/pull/4846#discussion_r145650965
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/calcite/FlinkCalciteSqlValidator.scala
---
@@ -48,4 +49,19 @@ class FlinkCalciteSqlValidator(
insert: SqlInsert): RelDataType = {
typeFactory.asInstanceOf[JavaTypeFactory].toSql(targetRowType)
}
+
+ override def validateJoin(join: SqlJoin, scope: SqlValidatorScope): Unit
= {
+ // Due to the improperly translation of lateral table left outer join
(see CALCITE-2004), we
+ // need to temporarily forbid the common predicates until the problem
is fixed.
+ // The check for join with a lateral table is actually quite tricky.
+ if (join.getJoinType == JoinType.LEFT &&
+ join.getRight.toString.startsWith("TABLE(")) { // TABLE
(`func`(`foo`)) AS...
--- End diff --
Yes, checking the string here may not be reliable and we need to search for
the node whose kind is `SqlKind.COLLECTION_TABLE`.
However, the recursive check could fail with subqueries. For instance,
given the following query,
```
SELECT *
FROM MyTable2 LEFT OUTER JOIN
(SELECT c, s
FROM MyTable LEFT OUTER JOIN LATERAL TABLE(func1(c)) AS T(s) on true)
ON c2 = s
```
the lateral table in the subquery will be detected by the out join. Thus I
think we should check the collection table, which should always be covered by
an `AS` node, directly, i.e.,
```
private def isCollectionTable(node: SqlNode): Boolean = {
node match {
case n: SqlCall if n.getKind == SqlKind.AS =>
n.getOperandList.get(0).getKind == SqlKind.COLLECTION_TABLE
}
}
```
What do you think?
> Reject lateral table outer joins with predicates in SQL
> -------------------------------------------------------
>
> Key: FLINK-7854
> URL: https://issues.apache.org/jira/browse/FLINK-7854
> Project: Flink
> Issue Type: Sub-task
> Components: Table API & SQL
> Reporter: Xingcan Cui
> Assignee: Xingcan Cui
> Priority: Blocker
> Fix For: 1.4.0
>
>
> Due to CALCITE-2004, lateral table outer joins can not be normally executed.
> We should cover it up by rejecting join predicates temporarily, until the
> issue is fixed in Calcite.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)