Github user dawidwys commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1981#discussion_r64728794
  
    --- 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 --
    
    I am not sure if the normalization to CNF is necessary. Calcite does not do 
it, but searches just the `AND` operators subtrees for equi conditions. E.g. 
For condition (l.a = r.b AND l.c =r.d) OR (l.a = r.b AND l.e = r.f) after 
transformation to CNF it will be possible to find equi condition, but Calcite 
is not finding it (see `RelOptUtil#splitJoinCondition`) and results in failing 
DataSet join.
    
    My proposition would be:
    
    1. traverse whole tree(both `OR` and `AND` branches) checking if only 
join-conditions exists
    2. check if equi-condition exists in `AND` branch
    
    What do you think @fhueske ?


---
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.
---

Reply via email to