Skip to content

[Bug] text column type len = 1 when create table as select  #13891

@nextdreamblue

Description

@nextdreamblue

Search before asking

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

Version

1.1.3-rc02-87ff019

What's Wrong?

MySQL [dwd_db]> CREATE TABLE test1 (
-> a int(11) NOT NULL COMMENT "",
-> b text NULL COMMENT ""
-> ) ENGINE=OLAP
-> DUPLICATE KEY(a)
-> COMMENT "OLAP"
-> DISTRIBUTED BY HASH(a) BUCKETS 10
-> PROPERTIES (
-> "replication_allocation" = "tag.location.default: 1",
-> "in_memory" = "false",
-> "storage_format" = "V2"
-> );
Query OK, 0 rows affected (0.02 sec)

MySQL [dwd_db]> create table test2 PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"in_memory" = "false",
"storage_format" = "V2"
)as select a ,lpad(b,10,'0') as b from test1;
Query OK, 0 rows affected (0.06 sec)
{'label':'insert_3ed1d3c23c3b4b79-9e960e4523ee3359', 'status':'VISIBLE', 'txnId':'8011'}

MySQL [dwd_db]> show create table test2\G
*************************** 1. row ***************************
Table: test2
Create Table: CREATE TABLE test2 (
a int(11) NOT NULL COMMENT "",
b text NULL COMMENT ""
) ENGINE=OLAP
DUPLICATE KEY(a)
COMMENT "OLAP"
DISTRIBUTED BY HASH(a) BUCKETS 10
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"in_memory" = "false",
"storage_format" = "V2"
);
1 row in set (0.00 sec)

MySQL [dwd_db]> insert into test2 values(1,'xxxx');
Query OK, 0 rows affected, 1 warning (0.03 sec)
{'label':'insert_21f97816765d4fed-9360b4e94489edd0', 'status':'VISIBLE', 'txnId':'8012'}

但是查看show load,会发现上次插入数据失败了,通过访问对应的http://9.134.167.25:8040/api/_load_error_log?fxxxx

Reason: the length of input is too long than schema. column_name: b; input str: [xxxx] schema length: 1; actual length: 4; . src line []; 

得到如上错误提示

然后通过调试查看test2的schema发现,该表的b字段类型虽然是text,但是长度只有1
image

这就导致后续的数据插入判断长度时失败

What You Expected?

字段类型长度正确,数据写入成功

How to Reproduce?

No response

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

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