[ 
https://issues.apache.org/jira/browse/FLINK-4541?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15673476#comment-15673476
 ] 

ASF GitHub Bot commented on FLINK-4541:
---------------------------------------

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

    https://github.com/apache/flink/pull/2811#discussion_r88434876
  
    --- Diff: 
flink-libraries/flink-table/src/test/scala/org/apache/flink/api/scala/batch/sql/CalcITCase.scala
 ---
    @@ -270,6 +271,24 @@ class CalcITCase(
       }
     
       @Test
    +  def testNotInWithNestedSelect(): Unit = {
    +    val env = ExecutionEnvironment.getExecutionEnvironment
    +    val tEnv = TableEnvironment.getTableEnvironment(env, config)
    +    tEnv.getConfig.setNullCheck(true)
    +
    +    val ds = CollectionDataSets.getSmall3TupleDataSet(env)
    +    val table = ds.toTable(tEnv).as('a1, 'a2, 'a3)
    +    tEnv.registerTable("A", table)
    +    val excludedVal = 1
    +    val sqlQuery = s"SELECT a1 FROM A WHERE a1 NOT IN (SELECT a1 FROM A 
WHERE a1 = $excludedVal)"
    +
    +    val expectedCnt = ds.collect.count(_._1 != excludedVal)
    +    val rowsCnt = tEnv.sql(sqlQuery).count
    --- End diff --
    
    Can we check the exact result here? ITCases are quite heavy, so it makes 
sense to make the check as precise as possible.


> Support for SQL NOT IN operator
> -------------------------------
>
>                 Key: FLINK-4541
>                 URL: https://issues.apache.org/jira/browse/FLINK-4541
>             Project: Flink
>          Issue Type: Improvement
>          Components: Table API & SQL
>            Reporter: Timo Walther
>            Assignee: Alexander Shoshin
>
> This should work:
> {code}
> def main(args: Array[String]): Unit = {
>     // set up execution environment
>     val env = ExecutionEnvironment.getExecutionEnvironment
>     val tEnv = TableEnvironment.getTableEnvironment(env)
>     val input = env.fromElements(WC("hello", 1), WC("hello", 1), WC("ciao", 
> 1))
>     // register the DataSet as table "WordCount"
>     tEnv.registerDataSet("WordCount", input, 'word, 'frequency)
>     tEnv.registerTable("WordCount2", tEnv.fromDataSet(input, 'word, 
> 'frequency).select('word).filter('word !== "hello"))
>     // run a SQL query on the Table and retrieve the result as a new Table
>     val table = tEnv.sql("SELECT word, SUM(frequency) FROM WordCount WHERE 
> word NOT IN (SELECT word FROM WordCount2) GROUP BY word")
>     table.toDataSet[WC].print()
>   }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to