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

Named windows do not work with MEDIAN() window function.

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 10.6.5, 10.3(EOL), 10.4(EOL), 10.5, 10.6
    • 10.5, 10.6
    • Parser
    • None
    • Ubuntu

    Description

      It's not possible to use a named WINDOW with the MEDIAN() window function.

      This does not work, but should. It gets 1064 near 'types AS med
      FROM items
      WINDOW types AS (PARTITION BY type)
      )
      SEL...' at line 7 */

      CREATE OR REPLACE TEMPORARY TABLE items (type INTEGER, value INTEGER);
      INSERT INTO items (type, value) VALUES (1,1), (1,3), (1,4), (2,10), (2,32), (2,42);
      WITH descriptive_statistics AS (
          SELECT TYPE,
                 ROW_NUMBER() OVER types AS rownum,
                 MIN(value) OVER types  AS MIN,
                 MAX(value) OVER types AS MAX,
                 AVG(value) OVER types AS AVG,
                 MEDIAN(VALUE) OVER types AS med   // <-gacks here. 
      	   FROM items
          WINDOW types AS (PARTITION BY type)
      )
      SELECT VERSION(), TYPE, MIN, MAX, AVG, med
      FROM descriptive_statistics 
      WHERE rownum = 1
      

      This does work:

      CREATE TEMPORARY TABLE items (type INTEGER, value INTEGER);
      INSERT INTO items (type, value) VALUES (1,1), (1,3), (1,4), (2,10), (2,32), (2,42);
      WITH descriptive_statistics AS (
          SELECT TYPE,
                 ROW_NUMBER() OVER types AS rownum,
                 MIN(value) OVER types  AS MIN,
                 MAX(value) OVER types AS MAX,
                 AVG(value) OVER types AS AVG,
                 MEDIAN(VALUE) OVER (PARTITION BY type) AS Med
      	   FROM items
          WINDOW types AS (PARTITION BY type)
      )
      SELECT VERSION(), TYPE, MIN, MAX, AVG, med
      FROM descriptive_statistics 
      WHERE rownum = 1
      

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              OllieJones Oliver Jones
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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