dolthub / dolt

Dolt – Git for Data
Apache License 2.0
17.89k stars 507 forks source link

Schema merge conflict when there should be a clean schema merge #8134

Open timsehn opened 3 months ago

timsehn commented 3 months ago
schema_conflicts/main> call dolt_merge('add-units');
+------+--------------+-----------+-----------------+
| hash | fast_forward | conflicts | message         |
+------+--------------+-----------+-----------------+
|      | 0            | 1         | conflicts found |
+------+--------------+-----------+-----------------+
1 row in set (0.00 sec)

schema_conflicts/main*> select * from dolt_status;
+------------+--------+-----------------+
| table_name | staged | status          |
+------------+--------+-----------------+
| weights    | 0      | schema conflict |
+------------+--------+-----------------+
1 row in set (0.00 sec)

schema_conflicts/main*> select * from dolt_schema_conflicts;
+------------+-------------------------------------------------------------------+-------------------------------------------------------------------+-------------------------------------------------------------------+------------------------------------------------------------------+
| table_name | base_schema                                                       | our_schema                                                        | their_schema                                                      | description                                                      |
+------------+-------------------------------------------------------------------+-------------------------------------------------------------------+-------------------------------------------------------------------+------------------------------------------------------------------+
| weights    | CREATE TABLE `weights` (                                          | CREATE TABLE `weights` (                                          | CREATE TABLE `weights` (                                          | incompatible column types for column 'weight': Float32 and Int32 |
|            |   `id` int NOT NULL,                                              |   `id` int NOT NULL,                                              |   `id` int NOT NULL,                                              |                                                                  |
|            |   `weight` int,                                                   |   `weight` float,                                                 |   `weight` int,                                                   |                                                                  |
|            |   PRIMARY KEY (`id`)                                              |   PRIMARY KEY (`id`)                                              |   `units` varchar(10),                                            |                                                                  |
|            | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; |   PRIMARY KEY (`id`)                                              |                                                                  |
|            |                                                                   |                                                                   | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; |                                                                  |
+------------+-------------------------------------------------------------------+-------------------------------------------------------------------+-------------------------------------------------------------------+------------------------------------------------------------------+
1 row in set (0.00 sec)

The merge base and add-units branch both have int as their type for weight column. main should be free to change the type of weight because that column is not modified on add-units. Resulting schema should be:

CREATE TABLE `weights` ( 
`id` int NOT NULL,
`weight` float,
`units` varchar(10),
PRIMARY KEY (`id`) 
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin