matrixorigin / matrixorigin/matrixone
[Bug]: tracker for remaining CTAS schema inconsistencies with MySQL
- Dominant language
- Go
- Stars
- 1.9k
- Forks
- 311
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 768
Description
### Is there an existing issue for the same bug?
- [X] I have checked the existing issues.
### Branch Name
main
### Commit ID
20346cae7da11d14218aeb82c9fd86ef2bfcfbb3
### Other Environment Information
```Markdown
- MO version: 8.0.30-MatrixOne-v
- MySQL version: 8.0.45
- Verify date: 2026-05-18
```
### Actual Behavior
After re-verifying #14792, several `CREATE TABLE ... AS SELECT` schema behaviors are still inconsistent with MySQL.
Already verified fixed:
- scene 5
- scene 7
Known MO-specific behavior not split into this tracker:
- `TEXT/BLOB DEFAULT NULL` printing difference in `show create table`
Still inconsistent with MySQL:
- aggregate functions in CTAS: `avg/sum/count/max/min`
- bitwise aggregate functions in CTAS: `bit_and/bit_or/bit_xor`
- plain `DECIMAL` column definition after CTAS
- `concat_ws` result column definition after CTAS
- `date_format` result column definition after CTAS
- `AUTO_INCREMENT` attribute is retained after CTAS
### Expected Behavior
The CTAS target schema should be consistent with MySQL for the remaining scenarios above.
### Steps to Reproduce
```Markdown
1. aggregate functions in CTAS
drop table if exists agg01;
drop table if exists math01;
create table math01 (col1 int default 0, col2 decimal, col3 float, col4 double not null);
insert into math01 values (1, 7382.4324, 432453.3243, -2930.321323);
insert into math01 values (-100, 3283.32324, 328932.0, -9392032);
insert into math01 values (22813, -241, 932342.4324, -0.1);
insert into math01 values (null, null, null, 10);
create table agg01 as
select avg(col1) as avgCol, sum(col2) as sumcol, count(col3) as countCol, max(col4) as maxCol, min(col4) as minCol
from math01;
show create table agg01;
desc agg01;
2. bitwise aggregate functions in CTAS
drop table if exists bit02;
drop table if exists bit01;
create table bit01 (col1 char(1), col2 int);
insert into bit01 values ('a',111),('a',110),('a',100),('a',000),('b',001),('b',011);
create table bit02 as
select bit_and(col2), bit_or(col2), bit_xor(col2)
from bit01;
show create table bit02;
desc bit02;
3. plain DECIMAL column after CTAS
drop table if exists dst01;
drop table if exists src01;
create table src01 (col7 decimal);
insert into src01 values (3232.000), (0.0001), (null);
create table dst01 as select * from src01;
show create table dst01;
desc dst01;
4. concat_ws result column after CTAS
drop table if exists string02;
drop table if exists string01;
create table string01 (col1 varchar(40), col2 char, col3 text default null);
insert into string01 values (' database system', 'a', 'x');
insert into string01 values (' string function ', '1', 'y');
insert into string01 values ('test create table as select', '0', null);
create table string02 as
select concat_ws(',', col1, 'abcde') as newCol
from string01;
show create table string02;
desc string02;
5. date_format result column after CTAS
drop table if exists time02;
drop table if exists time01;
create table time01(col1 date, col2 datetime, col3 timestamp, col4 time);
insert into time01 values ('2020-10-11', '2023-11-11 10:00:01', '1997-01-13 12:12:12.000', '12:12:12');
insert into time01 values ('1919-12-01', '1990-10-10 01:01:01', '2001-12-12 01:01:01.000', '10:59:59');
insert into time01 values (null, null, null, null);
create table time02 as
select date_format(col2, '%W %M %Y') from time01;
show create table time02;
desc time02;
6. AUTO_INCREMENT attribute retained after CTAS
drop table if exists table02;
drop table if exists table01;
create table table01 (
id int auto_increment primary key,
col1 varchar(255) not null
);
insert into table01 (col1) values ('Value2'), ('Value3');
create table table02 as select * from table01;
show create table table02;
desc table02;
```
### Additional information
This issue is a tracker that summarizes the remaining incompatible CTAS schema behaviors from #14792.
Contributor guide
Assessment
This issue has not been assessed yet.