Skip to content

fix: When a doris field has default value '' (empty str), the ddl to modify the column type is incorrectly#600

Merged
JNSimba merged 1 commit into
apache:masterfrom
potterhe:modify-column-type-with-default
Jun 11, 2025
Merged

fix: When a doris field has default value '' (empty str), the ddl to modify the column type is incorrectly#600
JNSimba merged 1 commit into
apache:masterfrom
potterhe:modify-column-type-with-default

Conversation

@potterhe
Copy link
Copy Markdown
Contributor

@potterhe potterhe commented Jun 5, 2025

Proposed changes

Problem Summary:

CREATE TABLE `modify_column_type_with_default_value2` (
  `id` int NOT NULL,
  `cname` varchar(10) NOT NULL DEFAULT ""
)
UNIQUE KEY(`id`)
DISTRIBUTED BY HASH(`id`) BUCKETS 1
PROPERTIES (
"replication_num" = "1"
);

call api to change cname column: varchar(10) -> varchar(11)

        String columnName = "cname";
        String newColumnType = "varchar(11)";
        FieldSchema field = new FieldSchema(columnName, newColumnType, "");
        schemaChangeManager.modifyColumnDataType(DATABASE, modifyColumnTbls, field);

doris throw exception

org.apache.doris.flink.exception.DorisSchemaChangeException: Failed to schemaChange, response: {"msg":"Error","code":1,"data":"Failed to execute sql: java.sql.SQLException: (conn=1786844) errCode = 2, detailMessage = Can not change default value","count":0}

The actual generated ddl is

ALTER TABLE `test_sc_db`.`modify_column_type_with_default_value2` MODIFY COLUMN `cname` varchar(11)

Expected generated ddl is

ALTER TABLE `test_sc_db`.`modify_column_type_with_default_value2` MODIFY COLUMN `cname` varchar(11) DEFAULT ''

Checklist(Required)

  1. Does it affect the original behavior: (Yes)
  2. Has unit tests been added: (Yes)
  3. Has document been added or modified: (No Need)
  4. Does it need to update dependencies: (No)
  5. Are there any changes that cannot be rolled back: (No)

Further comments

n/a

@potterhe potterhe force-pushed the modify-column-type-with-default branch from 84f3dc0 to 6da43df Compare June 5, 2025 10:14
Copy link
Copy Markdown
Member

@JNSimba JNSimba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JNSimba JNSimba merged commit 9e06de9 into apache:master Jun 11, 2025
6 checks passed
@JNSimba JNSimba mentioned this pull request Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants