hubgeter opened a new pull request, #22561:
URL: https://github.com/apache/doris/pull/22561
…l() bug
## Proposed changes
Issue Number: close #xxx
1. append show tables
when you `show table` , this result will be cache in
`internal.__internal_schema.cache_show_tables` table.
```
mysql> desc internal.__internal_schema.cache_show_tables;
+--------------+-------------+------+-------+---------+---------+
| Field | Type | Null | Key | Default | Extra |
+--------------+-------------+------+-------+---------+---------+
| catalog_id | BIGINT | No | true | NULL | |
| catalog_name | VARCHAR(64) | No | true | NULL | |
| database | VARCHAR(64) | No | true | NULL | |
| table | VARCHAR(64) | No | true | NULL | |
| update_time | DATETIME | No | false | NULL | REPLACE |
+--------------+-------------+------+-------+---------+---------+
5 rows in set (0.01 sec)
```
You can use `enable_cache_show_tables` variable to enable this function.
```mysql
set enable_cache_show_tables = true;
```
when you drop / refresh catalog xxx , the relevant information in the cache
table will be deleted.
2. fix bug : CreateTableStmt.toSql()
when i use `CreateTableStmt`:
```java
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();`.
before :
```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`
after :
```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");
```
<!--Describe your changes.-->
## Further comments
If this is a relatively large or complex change, kick off the discussion at
[[email protected]](mailto:[email protected]) 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]