Skip to content

Column type for aggregate column created from select does not match MySQL #9754

@angelamayxie

Description

@angelamayxie

MySQL

mysql> create table t1 (i int);
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t1 values (1);
Query OK, 1 row affected (0.00 sec)

mysql> create table t2 select sum(i) from t1;
Query OK, 1 row affected (0.01 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> show create table t2;
+-------+------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                 |
+-------+------------------------------------------------------------------------------------------------------------------------------+
| t2    | CREATE TABLE `t2` (
  `sum(i)` decimal(32,0) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
+-------+------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Dolt

tmp/main*> create table t1 (i int);
Query OK, 0 rows affected (0.01 sec)
tmp/main*> insert into t1 values (1);
Query OK, 1 row affected (0.01 sec)
tmp/main*> create table t2 select sum(i) from t1;
Query OK, 1 row affected (0.01 sec)
tmp/main*> show create table t2;
+-------+------------------------------------------------------------------+
| Table | Create Table                                                     |
+-------+------------------------------------------------------------------+
| t2    | CREATE TABLE `t2` (                                              |
|       |   `sum(t1.i)` double NOT NULL                                    |
|       | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin |
+-------+------------------------------------------------------------------+
1 row in set (0.00 sec) 

Column is decimal(32,0) DEFAULT NULL in MySQL but double NOT NULL in Dolt. TODO added in dolthub/go-mysql-server#3182

Column name is fixed in dolthub/vitess#430

Metadata

Metadata

Assignees

No one assigned

    Labels

    correctnessWe don't return the same result as MySQLsqlIssue with SQL

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions