Skip to content

[Bug]: CTAS with date_format infers result column definition differently from MySQL #24432

Closed

Description

@Ariznawlll

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

20346ca

Other Environment Information

- MO version: 8.0.30-MatrixOne-v
- MySQL version: 8.0.45
- Verify date: 2026-05-18

Actual Behavior

CREATE TABLE ... AS SELECT date_format(...) infers the result column name and type differently from MySQL.

MO:

CREATE TABLE `time02` (
  `date_format(col2, %w %m %y)` varchar(65535) DEFAULT NULL
)

MySQL:

CREATE TABLE `time02` (
  `date_format(col2, '%W %M %Y')` varchar(134) DEFAULT NULL
)

Expected Behavior

The CTAS result schema should be consistent with MySQL, including expression column name and inferred varchar length.

Steps to Reproduce

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;
select * from time02;

Additional information

Split from #14792 after re-verification.

Activity

  1. Ariznawlll commented on May 18, 2026

    @Ariznawlll
    CollaboratorAuthor

    Closing in favor of summary tracker #24436. This issue was split from #14792 during re-verification and is now tracked centrally in #24436.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions