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

Broken Sort operation with Union and Count

    XMLWordPrintable

    Details

      Description

      Simple unions break sorting.

      Here's a relatively simple query format that demonstrates this on a columnstore table:

      SELECT
      label,
      count
      FROM (
      SELECT
      label,
      COUNT(my_table.id) as count
      FROM my_table
      GROUP BY label
      UNION ALL
      SELECT "NONE" as label, 0 as count
      UNION ALL
      SELECT "NONE" as label, -1 as count

      ) AS A ORDER BY count

      This will yield a sort order where -1 is considered the largest value.

      This is likely a signed/unsigned integer issue.

      Of note:

      • Does not break on a Sum, have not tested other grouping operations
      • Have not tested other sort engines
      • Did not break in our previous version of columnstore some ~4 years ago

      Active Workaround:
      replace literal for -1 with cast(-1 AS float) acts as workaround

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            jkarlow Jared Karlow
            Votes:
            0 Vote for this issue
            Watchers:
            1 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.