Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-13742

Fix code generation when aggregation contains both distinct aggregate with and without filter

    XMLWordPrintableJSON

Details

    Description

      The following test will fail when the aggregation contains COUNT(DISTINCT c) and COUNT(DISTINCT c) filter ....

      	  @Test
        def testDistinctWithMultiFilter(): Unit = {
          val sqlQuery =
            "SELECT b, " +
              "  SUM(DISTINCT (a * 3)), " +
              "  COUNT(DISTINCT SUBSTRING(c FROM 1 FOR 2))," +
              "  COUNT(DISTINCT c)," +
              "  COUNT(DISTINCT c) filter (where MOD(a, 3) = 0)," +
              "  COUNT(DISTINCT c) filter (where MOD(a, 3) = 1) " +
              "FROM MyTable " +
              "GROUP BY b"
          val t = failingDataSource(StreamTestData.get3TupleData).toTable(tEnv).as('a, 'b, 'c)
          tEnv.registerTable("MyTable", t)
          val result = tEnv.sqlQuery(sqlQuery).toRetractStream[Row]
          val sink = new TestingRetractSink
          result.addSink(sink)
          env.execute()
          val expected = List(
            "1,3,1,1,0,1",
            "2,15,1,2,1,0",
            "3,45,3,3,1,1",
            "4,102,1,4,1,2",
            "5,195,1,5,2,1",
            "6,333,1,6,2,2")
          assertEquals(expected.sorted, sink.getRetractResults.sorted)
        }
      

      Attachments

        Issue Links

          Activity

            People

              icshuo Shuo Cheng
              jark Jark Wu
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m