Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class DescribeStmt extends ShowStmt {
.addColumn(new Column("IndexKeysType", ScalarType.createVarchar(20)))
.addColumn(new Column("Field", ScalarType.createVarchar(20)))
.addColumn(new Column("Type", ScalarType.createVarchar(20)))
.addColumn(new Column("InternalType", ScalarType.createVarchar(20)))
.addColumn(new Column("Null", ScalarType.createVarchar(10)))
.addColumn(new Column("Key", ScalarType.createVarchar(10)))
.addColumn(new Column("Default", ScalarType.createVarchar(30)))
Expand Down Expand Up @@ -130,6 +131,11 @@ public void analyze(Analyzer analyzer) throws UserException {
? FeConstants.null_string : column.getDefaultValue(),
"NONE"
);
if (column.getOriginType().isDatetimeV2()) {
row.set(1, "DATETIME");
} else if (column.getOriginType().isDateV2()) {
row.set(1, "DATE");
}
totalRows.add(row);
}
return;
Expand Down Expand Up @@ -205,6 +211,7 @@ public void analyze(Analyzer analyzer) throws UserException {
"",
column.getName(),
column.getOriginType().toString(),
column.getOriginType().toString(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是不是跟213 行重复了

Copy link
Contributor Author

@Cai-Yao Cai-Yao Apr 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是不是跟213 行重复了

不是,一个是替换后的type,一个是新加的InternalYype列

column.isAllowNull() ? "Yes" : "No",
((Boolean) column.isKey()).toString(),
column.getDefaultValue() == null
Expand All @@ -215,6 +222,12 @@ public void analyze(Analyzer analyzer) throws UserException {
column.getDefineExpr() == null ? "" : column.getDefineExpr().toSql(),
"");

if (column.getOriginType().isDatetimeV2()) {
row.set(3, "DATETIME");
} else if (column.getOriginType().isDateV2()) {
row.set(3, "DATE");
}

if (j == 0) {
row.set(0, indexName);
row.set(1, indexMeta.getKeysType().name());
Expand Down
20 changes: 18 additions & 2 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java
Original file line number Diff line number Diff line change
Expand Up @@ -633,14 +633,30 @@ public List<SlotRef> getRefColumns() {
}

public String toSql() {
return toSql(false);
return toSql(false, false);
}

public String toSql(boolean isUniqueTable) {
return toSql(isUniqueTable, false);
}

public String toSql(boolean isUniqueTable, boolean isCompatible) {
StringBuilder sb = new StringBuilder();
sb.append("`").append(name).append("` ");
String typeStr = type.toSql();
sb.append(typeStr);

// show change datetimeV2/dateV2 to datetime/date
if (isCompatible) {
if (type.isDatetimeV2()) {
sb.append("datetime");
} else if (type.isDateV2()) {
sb.append("date");
} else {
sb.append(typeStr);
}
} else {
sb.append(typeStr);
}
if (aggregationType != null && aggregationType != AggregateType.NONE && !isUniqueTable
&& !isAggregationTypeImplicit) {
sb.append(" ").append(aggregationType.name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2788,7 +2788,8 @@ public static void getDdlStmt(DdlStmt ddlStmt, String dbName, TableIf table, Lis
// There MUST BE 2 space in front of each column description line
// sqlalchemy requires this to parse SHOW CREATE TABLE stmt.
if (table.getType() == TableType.OLAP) {
sb.append(" ").append(column.toSql(((OlapTable) table).getKeysType() == KeysType.UNIQUE_KEYS));
sb.append(" ").append(
column.toSql(((OlapTable) table).getKeysType() == KeysType.UNIQUE_KEYS, true));
} else {
sb.append(" ").append(column.toSql());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ public ProcResult fetchResult() throws AnalysisException {
column.getDefaultValue() == null
? FeConstants.null_string : column.getDefaultValue(),
extraStr);

if (column.getOriginType().isDateV2()) {
rowList.set(1, "DATE");
}
if (column.getOriginType().isDatetimeV2()) {
rowList.set(1, "DATETIME");
}
result.addRow(rowList);
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ decimal64_key DECIMALV3(14, 1) No true \N BLOOM_FILTER
decimal128_key DECIMALV3(38, 1) No true \N BLOOM_FILTER
date_key DATE No true \N BLOOM_FILTER
datetime_key DATETIME No true \N BLOOM_FILTER
datev2_key DATEV2 No true \N BLOOM_FILTER
datetimev2_key_1 DATETIMEV2(0) No true \N BLOOM_FILTER
datetimev2_key_2 DATETIMEV2(3) No true \N BLOOM_FILTER
datetimev2_key_3 DATETIMEV2(6) No true \N BLOOM_FILTER
datev2_key DATE No true \N BLOOM_FILTER
datetimev2_key_1 DATETIME No true \N BLOOM_FILTER
datetimev2_key_2 DATETIME No true \N BLOOM_FILTER
datetimev2_key_3 DATETIME No true \N BLOOM_FILTER
tinyint_value TINYINT No false \N SUM
smallint_value SMALLINT No false \N SUM
int_value INT No false \N SUM
Expand All @@ -41,18 +41,18 @@ date_value_min DATE No false \N MIN
datetime_value_max DATETIME No false \N MAX
datetime_value_replace DATETIME No false \N REPLACE
datetime_value_min DATETIME No false \N MIN
datev2_value_max DATEV2 No false \N MAX
datev2_value_replace DATEV2 No false \N REPLACE
datev2_value_min DATEV2 No false \N MIN
datetimev2_value_1_max DATETIMEV2(0) No false \N MAX
datetimev2_value_1_replace DATETIMEV2(0) No false \N REPLACE
datetimev2_value_1_min DATETIMEV2(0) No false \N MIN
datetimev2_value_2_max DATETIMEV2(3) No false \N MAX
datetimev2_value_2_replace DATETIMEV2(3) No false \N REPLACE
datetimev2_value_2_min DATETIMEV2(3) No false \N MIN
datetimev2_value_3_max DATETIMEV2(6) No false \N MAX
datetimev2_value_3_replace DATETIMEV2(6) No false \N REPLACE
datetimev2_value_3_min DATETIMEV2(6) No false \N MIN
datev2_value_max DATE No false \N MAX
datev2_value_replace DATE No false \N REPLACE
datev2_value_min DATE No false \N MIN
datetimev2_value_1_max DATETIME No false \N MAX
datetimev2_value_1_replace DATETIME No false \N REPLACE
datetimev2_value_1_min DATETIME No false \N MIN
datetimev2_value_2_max DATETIME No false \N MAX
datetimev2_value_2_replace DATETIME No false \N REPLACE
datetimev2_value_2_min DATETIME No false \N MIN
datetimev2_value_3_max DATETIME No false \N MAX
datetimev2_value_3_replace DATETIME No false \N REPLACE
datetimev2_value_3_min DATETIME No false \N MIN
float_value FLOAT No false \N SUM
double_value DOUBLE No false \N SUM

Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ date_value_max DATE Yes false \N MAX
date_value_min DATE Yes false \N MIN
date_value_replace DATE Yes false \N REPLACE
date_value_replace_if_not_null DATE Yes false \N REPLACE_IF_NOT_NULL
datev2_value_max DATEV2 Yes false \N MAX
datev2_value_min DATEV2 Yes false \N MIN
datev2_value_replace DATEV2 Yes false \N REPLACE
datev2_value_replace_if_not_null DATEV2 Yes false \N REPLACE_IF_NOT_NULL
datetimev2_value_max DATETIMEV2(0) Yes false \N MAX
datetimev2_value_min DATETIMEV2(0) Yes false \N MIN
datetimev2_value_replace DATETIMEV2(0) Yes false \N REPLACE
datetimev2_value_replace_if_not_null DATETIMEV2(0) Yes false \N REPLACE_IF_NOT_NULL
datetimev2_value_max_1 DATETIMEV2(3) Yes false \N MAX
datetimev2_value_min_1 DATETIMEV2(3) Yes false \N MIN
datetimev2_value_replace_1 DATETIMEV2(3) Yes false \N REPLACE
datetimev2_value_replace_if_not_null_1 DATETIMEV2(3) Yes false \N REPLACE_IF_NOT_NULL
datetimev2_value_max_2 DATETIMEV2(6) Yes false \N MAX
datetimev2_value_min_2 DATETIMEV2(6) Yes false \N MIN
datetimev2_value_replace_2 DATETIMEV2(6) Yes false \N REPLACE
datetimev2_value_replace_if_not_null_2 DATETIMEV2(6) Yes false \N REPLACE_IF_NOT_NULL
datev2_value_max DATE Yes false \N MAX
datev2_value_min DATE Yes false \N MIN
datev2_value_replace DATE Yes false \N REPLACE
datev2_value_replace_if_not_null DATE Yes false \N REPLACE_IF_NOT_NULL
datetimev2_value_max DATETIME Yes false \N MAX
datetimev2_value_min DATETIME Yes false \N MIN
datetimev2_value_replace DATETIME Yes false \N REPLACE
datetimev2_value_replace_if_not_null DATETIME Yes false \N REPLACE_IF_NOT_NULL
datetimev2_value_max_1 DATETIME Yes false \N MAX
datetimev2_value_min_1 DATETIME Yes false \N MIN
datetimev2_value_replace_1 DATETIME Yes false \N REPLACE
datetimev2_value_replace_if_not_null_1 DATETIME Yes false \N REPLACE_IF_NOT_NULL
datetimev2_value_max_2 DATETIME Yes false \N MAX
datetimev2_value_min_2 DATETIME Yes false \N MIN
datetimev2_value_replace_2 DATETIME Yes false \N REPLACE
datetimev2_value_replace_if_not_null_2 DATETIME Yes false \N REPLACE_IF_NOT_NULL

Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ k INT Yes true \N
int_value INT Yes false \N NONE
char_value CHAR(10) Yes false \N NONE
date_value DATE Yes false \N NONE
date_value2 DATEV2 Yes false \N NONE
date_value3 DATETIMEV2(0) Yes false \N NONE
date_value4 DATETIMEV2(3) Yes false \N NONE
date_value5 DATETIMEV2(6) Yes false \N NONE
date_value2 DATE Yes false \N NONE
date_value3 DATETIME Yes false \N NONE
date_value4 DATETIME Yes false \N NONE
date_value5 DATETIME Yes false \N NONE

-- !select_dup_table --
0 1 2 3
Expand Down
24 changes: 12 additions & 12 deletions regression-test/data/index_p0/test_bitmap_index.out
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ k8 DATETIME Yes false \N NONE
k9 LARGEINT Yes false \N NONE
k10 DECIMAL(9, 0) Yes false \N NONE
k11 BOOLEAN Yes false \N NONE
k12 DATEV2 Yes false \N NONE
k13 DATETIMEV2(0) Yes false \N NONE
k14 DATETIMEV2(3) Yes false \N NONE
k15 DATETIMEV2(6) Yes false \N NONE
k12 DATE Yes false \N NONE
k13 DATETIME Yes false \N NONE
k14 DATETIME Yes false \N NONE
k15 DATETIME Yes false \N NONE

-- !sql --
default_cluster:regression_test_index_p0.test_bitmap_index_dup index1 k1 BITMAP
Expand Down Expand Up @@ -48,10 +48,10 @@ k8 DATETIME Yes true \N
k9 LARGEINT Yes true \N
k10 DECIMAL(9, 0) Yes true \N
k11 BOOLEAN Yes true \N
k12 DATEV2 Yes true \N
k13 DATETIMEV2(0) Yes true \N
k14 DATETIMEV2(3) Yes true \N
k15 DATETIMEV2(6) Yes true \N
k12 DATE Yes true \N
k13 DATETIME Yes true \N
k14 DATETIME Yes true \N
k15 DATETIME Yes true \N
v1 INT Yes false \N SUM

-- !sql --
Expand Down Expand Up @@ -86,10 +86,10 @@ k8 DATETIME Yes true \N
k9 LARGEINT Yes true \N
k10 DECIMAL(9, 0) Yes true \N
k11 BOOLEAN Yes true \N
k12 DATEV2 Yes false \N REPLACE
k13 DATETIMEV2(0) Yes false \N REPLACE
k14 DATETIMEV2(3) Yes false \N REPLACE
k15 DATETIMEV2(6) Yes false \N REPLACE
k12 DATE Yes false \N REPLACE
k13 DATETIME Yes false \N REPLACE
k14 DATETIME Yes false \N REPLACE
k15 DATETIME Yes false \N REPLACE
v1 INT Yes false \N REPLACE

-- !sql --
Expand Down
4 changes: 4 additions & 0 deletions regression-test/data/query_p0/show/test_show_create_table.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select --
tb_show_create_table CREATE TABLE `tb_show_create_table` (\n `datek1` date NULL COMMENT 'a',\n `datetimek1` datetime NULL COMMENT 'b',\n `datetimek2` datetime NULL COMMENT 'c',\n `datetimek3` datetime NULL COMMENT 'd',\n `datev1` date MAX NOT NULL COMMENT 'e',\n `datetimev1` datetime MAX NOT NULL COMMENT 'f',\n `datetimev2` datetime MAX NOT NULL COMMENT 'g',\n `datetimev3` datetime MAX NOT NULL COMMENT 'h'\n) ENGINE=OLAP\nAGGREGATE KEY(`datek1`, `datetimek1`, `datetimek2`, `datetimek3`)\nCOMMENT 'OLAP'\nDISTRIBUTED BY HASH(`datek1`) BUCKETS 5\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 1",\n"in_memory" = "false",\n"storage_format" = "V2",\n"light_schema_change" = "true",\n"disable_auto_compaction" = "false"\n);

16 changes: 8 additions & 8 deletions regression-test/data/rollup/test_materialized_view_hll.out
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --
test_materialized_view_hll DUP_KEYS record_id INT Yes true \N true
seller_id INT Yes true \N true
store_id INT Yes true \N true
sale_date DATE Yes false \N NONE true
sale_amt BIGINT Yes false \N NONE true

amt_count AGG_KEYS mv_store_id INT Yes true \N true `store_id`
mva_HLL_UNION__hll_hash(`sale_amt`) HLL No false \N HLL_UNION true hll_hash(`sale_amt`)
test_materialized_view_hll DUP_KEYS record_id INT INT Yes true \N true
seller_id INT INT Yes true \N true
store_id INT INT Yes true \N true
sale_date DATE DATE Yes false \N NONE true
sale_amt BIGINT BIGINT Yes false \N NONE true
amt_count AGG_KEYS mv_store_id INT INT Yes true \N true `store_id`
mva_HLL_UNION__hll_hash(`sale_amt`) HLL HLL No false \N HLL_UNION true hll_hash(`sale_amt`)

-- !sql --
1 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --
test_materialized_view_hll_with_light_sc DUP_KEYS record_id INT Yes true \N true
seller_id INT Yes true \N true
store_id INT Yes true \N true
sale_date DATE Yes false \N NONE true
sale_amt BIGINT Yes false \N NONE true

amt_count1 AGG_KEYS mv_store_id INT Yes true \N true `store_id`
mva_HLL_UNION__hll_hash(`sale_amt`) HLL No false \N HLL_UNION true hll_hash(`sale_amt`)
test_materialized_view_hll_with_light_sc DUP_KEYS record_id INT INT Yes true \N true
seller_id INT INT Yes true \N true
store_id INT INT Yes true \N true
sale_date DATE DATE Yes false \N NONE true
sale_amt BIGINT BIGINT Yes false \N NONE true
amt_count1 AGG_KEYS mv_store_id INT INT Yes true \N true `store_id`
mva_HLL_UNION__hll_hash(`sale_amt`) HLL HLL No false \N HLL_UNION true hll_hash(`sale_amt`)

-- !sql --
1 1
Expand Down
60 changes: 30 additions & 30 deletions regression-test/data/rollup_p0/test_materialized_view.out
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --
test_materialized_view1 DUP_KEYS record_id INT Yes true \N true
seller_id INT Yes true \N true
store_id INT Yes true \N true
sale_date DATE Yes false \N NONE true
sale_amt BIGINT Yes false \N NONE true

amt_sum AGG_KEYS mv_store_id INT Yes true \N true `store_id`
mva_SUM__`sale_amt` BIGINT Yes false \N SUM true `sale_amt`

-- !sql --
test_materialized_view2 DUP_KEYS record_id INT Yes true \N true
seller_id INT Yes true \N true
store_id INT Yes true \N true
sale_date DATE Yes false \N NONE true
sale_amt BIGINT Yes false \N NONE true

seller_id_order DUP_KEYS mv_store_id INT Yes true \N true `store_id`
mv_seller_id INT Yes true \N true `seller_id`
mv_sale_amt BIGINT Yes false \N NONE true `sale_amt`
test_materialized_view1 DUP_KEYS record_id INT INT Yes true \N true
seller_id INT INT Yes true \N true
store_id INT INT Yes true \N true
sale_date DATE DATE Yes false \N NONE true
sale_amt BIGINT BIGINT Yes false \N NONE true
amt_sum AGG_KEYS mv_store_id INT INT Yes true \N true `store_id`
mva_SUM__`sale_amt` BIGINT BIGINT Yes false \N SUM true `sale_amt`

-- !sql --
test_materialized_view2 DUP_KEYS record_id INT INT Yes true \N true
seller_id INT INT Yes true \N true
store_id INT INT Yes true \N true
sale_date DATE DATE Yes false \N NONE true
sale_amt BIGINT BIGINT Yes false \N NONE true
seller_id_order DUP_KEYS mv_store_id INT INT Yes true \N true `store_id`
mv_seller_id INT INT Yes true \N true `seller_id`
mv_sale_amt BIGINT BIGINT Yes false \N NONE true `sale_amt`

-- !sql --
1 1 1 2020-05-30 100
Expand All @@ -35,17 +35,17 @@ seller_id_order DUP_KEYS mv_store_id INT Yes true \N true `store_id`
1 200

-- !sql --


mva_SUM__CASE WHEN `sale_amt` IS NULL THEN 0 ELSE 1 END BIGINT No false \N SUM true CASE WHEN `sale_amt` IS NULL THEN 0 ELSE 1 END
mva_SUM__`sale_amt` BIGINT Yes false \N SUM true `sale_amt`
sale_amt BIGINT Yes false \N NONE true
sale_date DATE Yes false \N NONE true
seller_id INT Yes true \N true
store_id INT Yes true \N true
amt_count AGG_KEYS mv_store_id INT Yes true \N true `store_id`
amt_sum AGG_KEYS mv_store_id INT Yes true \N true `store_id`
test_materialized_view1 DUP_KEYS record_id INT Yes true \N true
mva_SUM__CASE WHEN `sale_amt` IS NULL THEN 0 ELSE 1 END BIGINT BIGINT No false \N SUM true CASE WHEN `sale_amt` IS NULL THEN 0 ELSE 1 END
mva_SUM__`sale_amt` BIGINT BIGINT Yes false \N SUM true `sale_amt`
sale_amt BIGINT BIGINT Yes false \N NONE true
sale_date DATE DATE Yes false \N NONE true
seller_id INT INT Yes true \N true
store_id INT INT Yes true \N true
amt_count AGG_KEYS mv_store_id INT INT Yes true \N true `store_id`
amt_sum AGG_KEYS mv_store_id INT INT Yes true \N true `store_id`
test_materialized_view1 DUP_KEYS record_id INT INT Yes true \N true

-- !sql --
1 2
Expand Down
20 changes: 10 additions & 10 deletions regression-test/data/rollup_p0/test_rollup_agg.out
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --
test_rollup_agg AGG_KEYS siteid INT No true \N true
citycode SMALLINT No true \N true
username VARCHAR(32) No true \N true
pv BIGINT No false 0 SUM true
uv BIGINT No false 0 SUM true
vv BIGINT Yes false 0 SUM true

rollup_city AGG_KEYS citycode SMALLINT No true \N true
pv BIGINT No false 0 SUM true
vv BIGINT Yes false 0 SUM true
test_rollup_agg AGG_KEYS siteid INT INT No true \N true
citycode SMALLINT SMALLINT No true \N true
username VARCHAR(32) VARCHAR(32) No true \N true
pv BIGINT BIGINT No false 0 SUM true
uv BIGINT BIGINT No false 0 SUM true
vv BIGINT BIGINT Yes false 0 SUM true
rollup_city AGG_KEYS citycode SMALLINT SMALLINT No true \N true
pv BIGINT BIGINT No false 0 SUM true
vv BIGINT BIGINT Yes false 0 SUM true

-- !sql --
1 200
Expand Down
Loading