[
https://issues.apache.org/jira/browse/FLINK-7854?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16208539#comment-16208539
]
ASF GitHub Bot commented on FLINK-7854:
---------------------------------------
Github user fhueske commented on a diff in the pull request:
https://github.com/apache/flink/pull/4846#discussion_r145277609
--- 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 --
I don't free comfortable to check the string representation here.
There should be a better way, maybe recursively checking for
`SqlKind.COLLECTION_TABLE`:
```
private def isCollectionTable(node: SqlNode): Boolean = {
if (node.getKind == SqlKind.COLLECTION_TABLE) {
true
} else {
node match {
case c: SqlCall => c.getOperandList.asScala.filter(_ !=
null).exists(o => isCollectionTable(o))
case l: SqlNodeList => l.getList.asScala.filter(_ != null).exists(o
=> isCollectionTable(o))
case _ => false
}
}
}
```
This method passes all tests, but I'm not 100% that it is correct and won't
break for more complex queries.
Maybe there's also some methods in `SqlValidatorImpl` that are helpful.
> 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)