wuwenchi opened a new pull request, #35279: URL: https://github.com/apache/doris/pull/35279
## Proposed changes ### problem The current partition type of doris does not support string, If you use the string type as a partition field, an error will be reported. like: 1. CREATE TABLE : ``` mysql> create table tb2 (id int, val string) DUPLICATE KEY(`id`) auto partition by list (val)() DISTRIBUTED BY HASH(`id`) BUCKETS 1 properties("replication_num" = "1"); ERROR 1105 (HY000): errCode = 2, detailMessage = String Type should not be used in partition column[val]. ``` 2. CTAS : ``` mysql> use hive_emr.mmc_hive; mysql> create table tb11 (id int, val string, val2 string); Query OK, 0 rows affected (0.04 sec) mysql> insert into tb11 values (1, 'a', 'a'); Query OK, 1 row affected (0.13 sec) {'status':'COMMITTED', 'txnId':'55029'} mysql> use internal.doris; mysql> create table tb3 auto partition by list (val)() properties("replication_num" = "1") as select * from hive_emr.mmc_hive.tb11; ERROR 1105 (HY000): errCode = 2, detailMessage = String Type should not be used in partition column[val]. ``` ### solution This PR supports automatic conversion of string to varchar(65533), so, when using a CTAS table and using string for partitioning, it can still be successful. like: 1. create table: ``` mysql> create table tb2 (id int, val string) DUPLICATE KEY(`id`) auto partition by list (val)() DISTRIBUTED BY HASH(`id`) BUCKETS 1 properties("replication_num" = "1"); Query OK, 0 rows affected (0.01 sec) mysql> desc tb2; +-------+----------------+------+-------+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+----------------+------+-------+---------+-------+ | id | INT | Yes | true | NULL | | | val | VARCHAR(65533) | Yes | false | NULL | NONE | +-------+----------------+------+-------+---------+-------+ 2 rows in set (0.00 sec) ``` 2. CTAS ``` mysql> create table tb3 auto partition by list (val)() properties("replication_num" = "1") as select * from hive_emr.mmc_hive.tb11; Query OK, 1 row affected (0.25 sec) {'label':'label_e6a6e62b4ee543d2_8fb42e7b1c829f6f', 'status':'VISIBLE', 'txnId':'11013'} mysql> desc tb3; +-------+----------------+------+-------+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+----------------+------+-------+---------+-------+ | id | INT | Yes | true | NULL | | | val | VARCHAR(65533) | Yes | true | NULL | | | val2 | TEXT | Yes | false | NULL | NONE | +-------+----------------+------+-------+---------+-------+ 3 rows in set (0.01 sec) mysql> select * from tb3; +------+------+------+ | id | val | val2 | +------+------+------+ | 1 | a | a | +------+------+------+ 1 row in set (0.05 sec) ``` <!--Describe your changes.--> ## Further comments If this is a relatively large or complex change, kick off the discussion at [d...@doris.apache.org](mailto:d...@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc... -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org