hubgeter opened a new issue, #22749:
URL: https://github.com/apache/doris/issues/22749

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Version
   
   master 
   
   ### What's Wrong?
   
   when i use CreateTableStmt:
   ```mysql
   List<ColumnDef> columnDefs = new ArrayList<>();
   columnDefs.add(new ColumnDef("catalog_id", 
TypeDef.create(PrimitiveType.BIGINT), false));
   columnDefs.add(new ColumnDef("catalog_name",
           TypeDef.createVarchar(StatisticConstants.MAX_NAME_LEN), false));
   columnDefs.add(new ColumnDef("database_name",
           TypeDef.createVarchar(StatisticConstants.MAX_NAME_LEN), false));
   columnDefs.add(new ColumnDef("table", 
TypeDef.createVarchar(StatisticConstants.MAX_NAME_LEN), false));
   columnDefs.add(new ColumnDef("update_time", 
TypeDef.create(PrimitiveType.DATETIME), false));
   columnDefs.get(columnDefs.size() - 
1).setAggregateType(AggregateType.REPLACE);
   
   String engineName = "olap";
   ArrayList<String> aggKeys = Lists.newArrayList("catalog_id", "catalog_name", 
"databases", "table");
   KeysDesc keysDesc = new KeysDesc(KeysType.AGG_KEYS, aggKeys);
   DistributionDesc distributionDesc = new HashDistributionDesc(
           StatisticConstants.STATISTIC_TABLE_BUCKET_COUNT, 
Lists.newArrayList("catalog_id"));
   Map<String, String> properties = new HashMap<String, String>() {
       {
           put("replication_num", String.valueOf(Math.max(1,
                   Config.min_replication_num_per_tablet)));
       }
   };
   TableName tableName = new TableName("internal", "__internal_schema", 
"cache_show_tables");
   CreateTableStmt createTableStmt = new CreateTableStmt(true, false,
           tableName, columnDefs, engineName, keysDesc, null, distributionDesc,
           properties, null, "", null);
   ```
   then run `createTableStmt.toSql();`
   
   
   ```mysql
   CREATE TABLE internal.__internal_schema.cache_show_tables (
     `catalog_id` bigint(20) NOT NULL COMMENT "",
     `catalog_name` varchar(64) NOT NULL COMMENT "",
     `databases` varchar(64) NOT NULL COMMENT "",
     `table` varchar(64) NOT NULL COMMENT "",
     `update_time` datetime REPLACE NOT NULL COMMENT ""
   ) ENGINE = olap
   AGG_KEY(`catalog_id`, `catalog_name`, `databases`, `table`)
   DISTRIBUTED BY HASH(`catalog_id`)
   BUCKETS 7
   PROPERTIES ("replication_num"  =  "1");
   ```
   
   error : `AGG_KEY` 
   miss : `IF NOT EXISTS`
   
   
   ### What You Expected?
   
   ```mysql
   
   CREATE TABLE IF NOT EXISTS internal.__internal_schema .cache_show_tables (
     `catalog_id` bigint(20) NOT NULL COMMENT "",
     `catalog_name` varchar(64) NOT NULL COMMENT "",
     `databases` varchar(64) NOT NULL COMMENT "",
     `table` varchar(64) NOT NULL COMMENT "",
     `update_time` datetime REPLACE NOT NULL COMMENT ""
   ) ENGINE = olap
   AGGREGATE KEY(`catalog_id`, `catalog_name`, `databases`, `table`)
   DISTRIBUTED BY HASH(`catalog_id`)
   BUCKETS 7
   PROPERTIES ("replication_num"  =  "1");
   
   ```
   
   ### How to Reproduce?
   
   _No response_
   
   ### Anything Else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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.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

Reply via email to