Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] creataTableStmt tosql error #22749

Closed
3 tasks done
hubgeter opened this issue Aug 8, 2023 · 1 comment
Closed
3 tasks done

[Bug] creataTableStmt tosql error #22749

hubgeter opened this issue Aug 8, 2023 · 1 comment

Comments

@hubgeter
Copy link
Contributor

hubgeter commented Aug 8, 2023

Search before asking

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

Version

master

What's Wrong?

when i use CreateTableStmt:

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();

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?

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?

  • Yes I am willing to submit a PR!

Code of Conduct

@hubgeter
Copy link
Contributor Author

hubgeter commented Aug 8, 2023

pr : #22750

airborne12 pushed a commit to airborne12/apache-doris that referenced this issue Aug 21, 2023
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

No branches or pull requests

1 participant