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

Window functions without column references get removed from ORDER BY

Details

    Description

      create table t1 (id int, first_name varchar(100), last_name varchar(100), score double);
      create index t1_name on t1 (first_name, last_name);
      insert into t1 values
      (1, 'Alice', 'Fowler', 5),
      (2, 'John', 'Doe', 6),
      (3, 'John', 'Smith', 6),
      (4, 'John', 'Smith', 6),
      (5, 'John', 'Smith', 7),
      (6, 'John', 'Elton', 8.1),
      (7, 'Bob',  'Trasc', 9),
      (8, 'Silvia', 'Ganush', 10);
      select first_name fn, last_name ln, row_number() over () rn
      from t1
      order by rn desc;
      

      fn	ln	rn
      Alice	Fowler	1
      Bob	Trasc	2
      John	Smith	3
      John	Smith	4
      John	Smith	5
      John	Elton	6
      John	Doe	7
      Silvia	Ganush	8
      

      The DESC keyword is being ignored.

      Attachments

        Activity

          cvicentiu Vicențiu Ciorbaru created issue -
          cvicentiu Vicențiu Ciorbaru made changes -
          Field Original Value New Value
          Component/s Optimizer - Window functions [ 13502 ]
          cvicentiu Vicențiu Ciorbaru made changes -
          Assignee Vicențiu Ciorbaru [ cvicentiu ]
          cvicentiu Vicențiu Ciorbaru made changes -
          Description {code:sql}
          select first_name fn, last_name ln, row_number() over () rn
          from t1
          order by rn desc;
          {code}
          {code}
          fn ln rn
          Alice Fowler 1
          Bob Trasc 2
          John Smith 3
          John Smith 4
          John Smith 5
          John Elton 6
          John Doe 7
          Silvia Ganush 8
          {code}

          The DESC keyword is being ignored.
          {code:sql}
          create table t1 (id int, first_name varchar(100), last_name varchar(100), score double);
          create index t1_name on t1 (first_name, last_name);
          insert into t1 values
          (1, 'Alice', 'Fowler', 5),
          (2, 'John', 'Doe', 6),
          (3, 'John', 'Smith', 6),
          (4, 'John', 'Smith', 6),
          (5, 'John', 'Smith', 7),
          (6, 'John', 'Elton', 8.1),
          (7, 'Bob', 'Trasc', 9),
          (8, 'Silvia', 'Ganush', 10);
          select first_name fn, last_name ln, row_number() over () rn
          from t1
          order by rn desc;
          {code}
          {code}
          fn ln rn
          Alice Fowler 1
          Bob Trasc 2
          John Smith 3
          John Smith 4
          John Smith 5
          John Elton 6
          John Doe 7
          Silvia Ganush 8
          {code}

          The DESC keyword is being ignored.
          cvicentiu Vicențiu Ciorbaru made changes -
          Fix Version/s 10.2 [ 14601 ]
          cvicentiu Vicențiu Ciorbaru made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          cvicentiu Vicențiu Ciorbaru made changes -
          Assignee Vicențiu Ciorbaru [ cvicentiu ] Sergei Petrunia [ psergey ]
          Status In Progress [ 3 ] In Review [ 10002 ]
          psergei Sergei Petrunia made changes -
          Assignee Sergei Petrunia [ psergey ] Vicențiu Ciorbaru [ cvicentiu ]
          Status In Review [ 10002 ] Stalled [ 10000 ]
          cvicentiu Vicențiu Ciorbaru made changes -
          Fix Version/s 10.5.10 [ 25204 ]
          Fix Version/s 10.4.19 [ 25205 ]
          Fix Version/s 10.3.29 [ 25206 ]
          Fix Version/s 10.2.38 [ 25207 ]
          Fix Version/s 10.2 [ 14601 ]
          Resolution Fixed [ 1 ]
          Status Stalled [ 10000 ] Closed [ 6 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 119677 ] MariaDB v4 [ 158983 ]

          People

            cvicentiu Vicențiu Ciorbaru
            cvicentiu Vicențiu Ciorbaru
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.