flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fhueske <...@git.apache.org>
Subject [GitHub] flink pull request #3033: [FLINK-5256] Extend DataSetSingleRowJoin to suppor...
Date Tue, 17 Jan 2017 14:39:03 GMT
Github user fhueske commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3033#discussion_r96420110
  
    --- Diff: flink-libraries/flink-table/src/test/scala/org/apache/flink/table/api/scala/batch/sql/DataSetSingleRowJoinTest.scala
---
    @@ -192,4 +192,145 @@ class SingleRowJoinTest extends TableTestBase {
     
         util.verifySql(query, expected)
       }
    +
    +  @Test
    +  def testSingleRowJoinLeftOuterJoin(): Unit = {
    +    val util = batchTestUtil()
    +    util.addTable[(Int, Int)]("A", 'a1, 'a2)
    +    util.addTable[(Int, Int)]("B", 'b1, 'b2)
    +
    +    val queryLeftJoin =
    +      "SELECT a2 FROM A " +
    +        "LEFT JOIN " +
    +        "(SELECT COUNT(*) AS cnt FROM B) " +
    +        "AS x " +
    +        "ON a1 < cnt"
    +
    +    val expected =
    +      unaryNode(
    +        "DataSetCalc",
    +        unaryNode(
    +          "DataSetSingleRowJoin",
    +          batchTableNode(0),
    +          term("where", "<(a1, cnt)"),
    +          term("join", "a1", "a2", "cnt"),
    +          term("joinType", "NestedLoopJoin")
    +        ),
    +        term("select", "a2")
    +      ) + "\n" +
    +        unaryNode(
    +          "DataSetAggregate",
    +          unaryNode(
    +            "DataSetUnion",
    +            unaryNode(
    +              "DataSetValues",
    +              unaryNode(
    +                "DataSetCalc",
    +                batchTableNode(1),
    +                term("select", "0 AS $f0")),
    +              tuples(List(null)), term("values", "$f0")
    +            ),
    +            term("union", "$f0")
    +          ),
    +          term("select", "COUNT(*) AS cnt")
    +        )
    +
    +    util.verifySql(queryLeftJoin, expected)
    +  }
    +
    +  @Test
    +  def testSingleRowJoinRightOuterJoin(): Unit = {
    +    val util = batchTestUtil()
    +    util.addTable[(Int, Int)]("A", 'a1, 'a2)
    +    util.addTable[(Int, Int)]("B", 'b1, 'b2)
    +
    +    val queryRightJoin =
    +      "SELECT a2 FROM A " +
    +        "RIGHT JOIN " +
    +        "(SELECT COUNT(*) AS cnt FROM B) " +
    --- End diff --
    
    This should not be allowed. It should rather be
    ```
    SELECT a2 
    FROM 
      (SELECT COUNT(*) AS cnt FROM B)
        RIGHT JOIN
      A
    ```
    
    The single input must always be on the inner side and the multi input on the outer side.

    We should add test cases for left and right outer join to check that this condition is
not violated.


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

Mime
View raw message