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

after changing CAST() in group clause to CAST(CAST()), result unexpectedly become an empty set.

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Duplicate
    • 12.1.2
    • N/A
    • N/A
    • None
    • Not for Release Notes

    Description

      after changing CAST() in group clause to CAST(CAST()), result unexpectedly become an empty set.Compared with MDEV-38750,the difference locates group clause

      mysql> SELECT DISTINCT t2.c16 AS c16, CAST(t2.c14 AS FLOAT) AS col_1, STDDEV_POP(t2.c2) AS col_1_2 FROM t2 AS t2 CROSS JOIN t3 AS t3 ON (t3.c3 = t2.c1) GROUP BY t2.c16, CAST(t2.c14 AS FLOAT) HAVING NOT ST_COLLECT(77) IS NULL;
      +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------+---------+
      | c16                                                                                                                                                                      | col_1 | col_1_2 |
      +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------+---------+
      | {"k1": {"k2": 324, "k3": "user_33", "k4": {"k5": 24, "k6": "user12@example.com", "k7": {"k8": "city_39", "k9": "Sample Country"}}}, "k10": "2026-01-22T17:38:11.814999"} | 16.17 |  0.0000 |
      +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------+---------+
      1 row in set (0.00 sec)
       
      mysql> SELECT DISTINCT t2.c16 AS c16, CAST(t2.c14 AS FLOAT) AS col_1, STDDEV_POP(t2.c2) AS col_1_2 FROM t2 AS t2 CROSS JOIN t3 AS t3 ON (t3.c3 = t2.c1) GROUP BY t2.c16, CAST(CAST(t2.c14 AS FLOAT) AS FLOAT) HAVING NOT ST_COLLECT(77) IS NULL;
      Empty set (0.00 sec)
      

      How to repeat

      DROP DATABASE IF EXISTS test;
      CREATE DATABASE IF NOT EXISTS test;
      SET GLOBAL sort_buffer_size = 64 * 1024 * 1024;
      SET GLOBAL read_rnd_buffer_size = 8 * 1024 * 1024;
      USE test;
       
      CREATE TABLE t2 (
          c1 INT NOT NULL AUTO_INCREMENT,
          c2 INT NOT NULL,
          c14 FLOAT(8,2) NULL,
          c16 JSON NULL,
          PRIMARY KEY (c1)
      );
       
      CREATE TABLE t3 (
          c3 INT NOT NULL
      );
       
      INSERT INTO t2 (c1, c2, c14, c16) VALUES (7923, 6081, 16.17, '{"k1": {"k2": 324, "k3": "user_33", "k4": {"k5": 24, "k6": "user12@example.com", "k7": {"k8": "city_39", "k9": "Sample Country"}}}, "k10": "2026-01-22T17:38:11.814999"}');
       
       
      INSERT INTO t3 (c3) VALUES (7923);
       
      SELECT DISTINCT t2.c16 AS c16, CAST(t2.c14 AS FLOAT) AS col_1, STDDEV_POP(t2.c2) AS col_1_2 FROM t2 AS t2 CROSS JOIN t3 AS t3 ON (t3.c3 = t2.c1) GROUP BY t2.c16, CAST(t2.c14 AS FLOAT) HAVING NOT ST_COLLECT(77) IS NULL;
      SELECT DISTINCT t2.c16 AS c16, CAST(t2.c14 AS FLOAT) AS col_1, STDDEV_POP(t2.c2) AS col_1_2 FROM t2 AS t2 CROSS JOIN t3 AS t3 ON (t3.c3 = t2.c1) GROUP BY t2.c16, CAST(CAST(t2.c14 AS FLOAT) AS FLOAT) HAVING NOT ST_COLLECT(77) IS NULL;
      
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              chen7897 cl hl
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.