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

PERCENTILE_DISC() rejects temporal and string input

Details

    Description

      PERCENTILE_DISC() now return an error on temporal and string input:

      CREATE OR REPLACE TABLE t1 (name CHAR(30), star_rating TIME);
      INSERT INTO t1 VALUES ('Lord of the Ladybirds', '00:00:05');
      INSERT INTO t1 VALUES ('Lord of the Ladybirds', '00:00:03');
      INSERT INTO t1 VALUES ('Lady of the Flies', '00:00:01');
      INSERT INTO t1 VALUES ('Lady of the Flies', '00:00:02');
      INSERT INTO t1 VALUES ('Lady of the Flies', '00:00:05');
      SELECT name, PERCENTILE_DISC(0.5)
        WITHIN GROUP (ORDER BY star_rating)
        OVER (PARTITION BY name) AS pc FROM t1;
      

      ERROR 4101 (HY000): Numeric datatype is required for percentile_disc function
      

      It should be extended to support all string and temporal data types.

      Note, PERCENTILE_DISC() previously crashed on temporal input. The patch for MDEV-20272 fixed the crash and made it return an error instead. Allowing temporal and string types in PERCENTILE_DISC() needs some refactoring, which was not desirable in 10.3.

      Refactoring needed:
      Item_sum_percentile_disc currently recursively derives from Item_sum_num, which cannot return string/temporal values by design.
      In order to support string/temporal data types in PERCENTILE_DISC(), Item_sum_percentile_disc should be moved to the Item_sum_hybrid
      branch in the hierarchy.

      It's not desirable to do such refactoring in 10.3 or 10.4.

      Attachments

        Issue Links

          Activity

            There are no comments yet on this issue.

            People

              bar Alexander Barkov
              bar Alexander Barkov
              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.