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

    https://github.com/apache/flink/pull/1981#discussion_r64778861
  
    --- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/plan/logical/operators.scala
 ---
    @@ -298,11 +338,40 @@ 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 : BinaryComparison) = exp.children match {
    +        case (x : JoinFieldReference) :: (y : JoinFieldReference) :: Nil
    +          if x.isFromLeftInput != y.isFromLeftInput => Unit
    +        case _ => failValidation(
    +          s"Only join predicates supported. For non-join predicates use 
Table#where.")
    +      }
    +
    +    var equiJoinFound = false
    +    def validateConditions(exp: Expression, isAndBranch: Boolean): Unit = 
exp match {
    +      case x: And => x.children.foreach(validateConditions(_, isAndBranch))
    +      case x: Or => x.children.foreach(validateConditions(_, isAndBranch = 
false))
    +      case x: EqualTo =>
    +        if (isAndBranch) {
    +          equiJoinFound = true
    +        }
    +        checkIfJoinCondition(x)
    +      case x: BinaryComparison => checkIfJoinCondition(x)
    +      case x => failValidation(s"Unsupported condition type: 
${x.getClass.getSimpleName}.")
    +    }
    +
    +    validateConditions(expression, isAndBranch = true)
    +    if (!equiJoinFound) {
    +      failValidation(s"At least one equi-join required.")
    --- End diff --
    
    Add the whole join predicate to the error message?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to