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

Flink SQL functions max/min/sum return duplicated records

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 1.12.1
    • None
    • None

    Description

      mysql data:

      id    offset

      1      1

      1      3

      1      2

      flinksql code:(I used flink-connector-jdbc_2.12:1.12.1)

       

       

      object FlinkSqlOnJdbcForMysql {
      def main(args: Array[String]): Unit =

      { val settings = EnvironmentSettings.newInstance().useBlinkPlanner().inBatchMode().build() val tableEnvironment = TableEnvironment.create(settings) tableEnvironment.executeSql("" + "CREATE TABLE test (" + " id BIGINT," + " `offset` INT," + " PRIMARY KEY (id) NOT ENFORCED" + ") WITH (" + " 'connector' = 'jdbc'," + " 'driver' = 'com.mysql.cj.jdbc.Driver'," + " 'url' = 'jdbc:mysql://127.0.0.1:3306/test?&serverTimezone=Asia/Shanghai'," + " 'username' = 'root'," + " 'password' = 'Project.03'," + " 'table-name' = 'test'," + " 'scan.fetch-size' = '1000'," + " 'scan.auto-commit' = 'true'" + ")") tableEnvironment.executeSql( "select id,max(`offset`) from test group by id").print() }

      }

       

      result:

      ---------------------------------+

      id EXPR$1

      ---------------------------------+

      1 1
      1 3
      1 2

      ---------------------------------+

      Result of max/min/sum is duplicated,

      but avg/count/last_value/first_value is ok.

       

       

       

       

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            raypon.wang Raypon Wang
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment