[optimize](desc) display the correct data type of aggStateType (#34968)

If a table column is AGG_STATE type, we can't get the clear defined data type if we use `desc tbl` statement.

create table a_table(
    k1 int null,
    k2 agg_state<max_by(int not null,int)> generic,
    k3 agg_state<group_concat(string)> generic
)
aggregate key (k1)
distributed BY hash(k1) buckets 3
properties("replication_num" = "1");

before optimize:

mysql> desc a_table;
+-------+------------------------------------------------+------+-------+---------+---------+
| Field | Type                                           | Null | Key   | Default | Extra   |
+-------+------------------------------------------------+------+-------+---------+---------+
| k1    | INT                                            | Yes  | true  | NULL    |         |
| k2    | org.apache.doris.catalog.AggStateType@239f771c | No   | false | NULL    | GENERIC |
| k3    | org.apache.doris.catalog.AggStateType@2e535f50 | No   | false | NULL    | GENERIC |
+-------+------------------------------------------------+------+-------+---------+---------+
3 rows in set (0.00 sec)


after optimize:

mysql> desc a_table;
+-------+------------------------------------+------+-------+---------+---------+
| Field | Type                               | Null | Key   | Default | Extra   |
+-------+------------------------------------+------+-------+---------+---------+
| k1    | INT                                | Yes  | true  | NULL    |         |
| k2    | AGG_STATE<max_by(INT, INT NULL)>   | No   | false | NULL    | GENERIC |
| k3    | AGG_STATE<group_concat(TEXT NULL)> | No   | false | NULL    | GENERIC |
+-------+------------------------------------+------+-------+---------+---------+


Co-authored-by: duanxujian <duanxujian@jd.com>
This commit is contained in:
Xujian Duan
2024-05-21 20:28:02 +08:00
committed by yiguolei
parent a8c24d7698
commit af7b16f213
7 changed files with 19 additions and 5 deletions

View File

@ -129,14 +129,13 @@ public class DescribeStmt extends ShowStmt {
for (Column column : columns) {
List<String> row = Arrays.asList(
column.getName(),
column.getOriginType().toString(),
column.getOriginType().hideVersionForVersionColumn(true),
column.isAllowNull() ? "Yes" : "No",
((Boolean) column.isKey()).toString(),
column.getDefaultValue() == null
? FeConstants.null_string : column.getDefaultValue(),
"NONE"
);
row.set(1, column.getOriginType().hideVersionForVersionColumn(false));
totalRows.add(row);
}
return;

View File

@ -68,14 +68,12 @@ public class IndexSchemaProcNode implements ProcNodeInterface {
String extraStr = StringUtils.join(extras, ",");
List<String> rowList = Arrays.asList(column.getDisplayName(),
column.getOriginType().toString(),
column.getOriginType().hideVersionForVersionColumn(true),
column.isAllowNull() ? "Yes" : "No",
((Boolean) column.isKey()).toString(),
column.getDefaultValue() == null
? FeConstants.null_string : column.getDefaultValue(),
extraStr);
rowList.set(1, column.getOriginType().hideVersionForVersionColumn(false));
result.addRow(rowList);
}
return result;