Skip to content

[Bug] 原表字段char(255)使用Create table like后,新表变成了char(1) #37192

@Danpilz

Description

@Danpilz

Search before asking

  • I had searched in the issues and found no similar issues.

Version

apache-doris-2.1.3-bin-x64

What's Wrong?

这是原表,包含了char(255)类型的字段

CREATE TABLE test_doris_huan_hang
(
	`id` INT NOT NULL,
	`name` CHAR(255),
	`address` VARCHAR(8000),
	`updt_time` DATETIME,
	`money` DECIMAL(16,4),
	`double_test` DECIMAL(16,2) NOT NULL,
	`float_test` DECIMAL(16,2),
	`log_text` STRING
)
UNIQUE KEY(`id`)
DISTRIBUTED BY HASH(`id`) BUCKETS AUTO
PROPERTIES (
	"replication_num" = "3",
	"light_schema_change" = "true"
);

使用create table like创建新表

CREATE TABLE `temp_d8fd87d7cc814c1c` LIKE test_doris_huan_hang;

使用show create table发现,新创建的表的char长度变为了1,导致插入数据时报错

CREATE TABLE `temp_d8fd87d7cc814c1c` (
  `id` INT NOT NULL,
  `name` CHAR(1) NULL,
  `address` VARCHAR(8000) NULL,
  `updt_time` DATETIME NULL,
  `money` DECIMAL(16, 4) NULL,
  `double_test` DECIMAL(16, 2) NOT NULL,
  `float_test` DECIMAL(16, 2) NULL,
  `log_text` TEXT NULL
) ENGINE=OLAP
UNIQUE KEY(`id`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`id`) BUCKETS AUTO
PROPERTIES (
"replication_allocation" = "tag.location.default: 3",
"min_load_replica_num" = "-1",
"is_being_synced" = "false",
"storage_medium" = "hdd",
"storage_format" = "V2",
"inverted_index_storage_format" = "V1",
"enable_unique_key_merge_on_write" = "true",
"light_schema_change" = "true",
"disable_auto_compaction" = "false",
"enable_single_replica_compaction" = "false",
"group_commit_interval_ms" = "10000",
"group_commit_data_bytes" = "134217728"
);

并且我测试char(254)就没有问题,只要长度小于255都不会出错,请问这是数据库的问题吗?麻烦查看下,谢谢!

What You Expected?

执行create table like需要能正确创建表结构

How to Reproduce?

按照上面的描述可复现

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions