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

agg max/min supports char type

    XMLWordPrintableJSON

Details

    Description

      // flink
      Flink SQL> CREATE TABLE Orders (
      >     name char(10),
      >     price        DECIMAL(32,2),
      >     buyer        ROW<first_name STRING, last_name STRING>,
      >     order_time   TIMESTAMP(3)
      > ) WITH (
      >   'connector' = 'datagen'
      > );
      [INFO] Execute statement succeed.
      
      
      Flink SQL> select max(name) from Orders;
      [ERROR] Could not execute SQL statement. Reason:
      org.apache.flink.table.api.TableException: Max aggregate function does not support type: ''CHAR''.
      Please re-check the data type. 
      // mysql
      
      CREATE TABLE IF NOT EXISTS `docs` (
        `id` int(6) unsigned NOT NULL,
        `rev` int(3) unsigned NOT NULL,
        `content` char(200) NOT NULL,
        PRIMARY KEY (`id`,`rev`)
      ) DEFAULT CHARSET=utf8;
      INSERT INTO `docs` (`id`, `rev`, `content`) VALUES
        ('1', '1', 'The earth is flat'),
        ('2', '1', 'One hundred angels can dance on the head of a pin'),
        ('1', '2', 'The earth is flat and rests on a bull\'s horn'),
        ('1', '3', 'The earth is like a ball.');
      
      select max(content) from docs;
      
      // result 
      |max(content)|
      The earth is like a ball.

      Attachments

        Issue Links

          Activity

            People

              jackylau Jacky Lau
              jackylau Jacky Lau
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: