Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-19052

Range-type window frame supports only numeric datatype

    XMLWordPrintable

Details

    Description

      create table t1 (a int, b varchar(5));
      insert into t1 values (1,'a'), (2, 'b'), (3, 'c');
       
      select sum(a) over (order by b range between unbounded preceding and current row) from t1;
      

      MariaDB [test]> select sum(a) over (order by b range between unbounded preceding and current row) from t1;
      ERROR 4021 (HY000): Numeric datatype is required for RANGE-type frame
      

      Mysql/Postgres return:

      mysql> select sum(a) over (order by b range between unbounded preceding and current row) from t1;
      +----------------------------------------------------------------------------+
      | sum(a) over (order by b range between unbounded preceding and current row) |
      +----------------------------------------------------------------------------+
      |                                                                          1 |
      |                                                                          3 |
      |                                                                          6 |
      +----------------------------------------------------------------------------+
      3 rows in set (0.00 sec)
      

      Also range-type frame always expects ORDER BY clause:

      MariaDB [test]> select sum(a) over (range between unbounded preceding and current row) from t1;
      ERROR 4019 (HY000): RANGE-type frame requires ORDER BY clause with single sort key
      

      Mysql 8.0.15:

      mysql> select sum(a) over (range between unbounded preceding and current row) from t1;
      +-----------------------------------------------------------------+
      | sum(a) over (range between unbounded preceding and current row) |
      +-----------------------------------------------------------------+
      |                                                               6 |
      |                                                               6 |
      |                                                               6 |
      +-----------------------------------------------------------------+
      3 rows in set (0.00 sec)
      

      Attachments

        Issue Links

          Activity

            People

              danblack Daniel Black
              alice Alice Sherepa
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.