Github user fhueske commented on a diff in the pull request:
https://github.com/apache/flink/pull/1981#discussion_r64710283
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/plan/logical/operators.scala
---
@@ -298,11 +333,34 @@ case class Join(
val resolvedJoin = super.validate(tableEnv).asInstanceOf[Join]
if (!resolvedJoin.condition.forall(_.resultType == BOOLEAN_TYPE_INFO))
{
failValidation(s"filter expression ${resolvedJoin.condition} is not
a boolean")
- } else if (!ambiguousName.isEmpty) {
+ } else if (ambiguousName.nonEmpty) {
failValidation(s"join relations with ambiguous names:
${ambiguousName.mkString(", ")}")
}
+
+ resolvedJoin.condition.foreach(testJoinCondition(_))
resolvedJoin
}
+
+ private def testJoinCondition(expression: Expression): Unit = {
+ def checkIfJoinCondition(exp : Expression) = if
(exp.children.exists(!_.isInstanceOf[JoinFieldReference])) {
+ failValidation(s"Only join predicates supported. For non-join
predicates use Table#where.")
+ }
+
+ var equiJoinFound = false
+ def validateConditions(exp: Expression) : Unit = exp match {
--- End diff --
Checking whether it is an equi-join is a bit more difficult. For instance
`l.a = r.b AND (l.c = r.d OR l.c = r.e)` is a valid equi-join condition. The
first condition `(l.a = r.b)` can be pushed in the DataSet join
(`left.join(right).where(a).equalTo(b)`) and the remaining condition can be
evaluated in the `JoinFunction`.
To do the check, the predicate should be first normalized into "Conjunctive
Normal Form" (CNF). Once that is done, the check is easy.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---