From 0acbbaf5f39c7c0804be9b2c423a88b3552b5440 Mon Sep 17 00:00:00 2001 From: Cai-Yao <729673078@qq.com> Date: Fri, 7 Apr 2023 16:06:49 +0800 Subject: [PATCH 1/2] show dateV2/datetimeV2 to date/datetime --- .../apache/doris/analysis/DescribeStmt.java | 20 ++++++++ .../java/org/apache/doris/catalog/Column.java | 20 +++++++- .../java/org/apache/doris/catalog/Env.java | 3 +- .../test_create_table_with_bloom_filter.out | 32 ++++++------- .../aggregate/test_aggregate_table.out | 32 ++++++------- .../duplicate/test_duplicate_table.out | 8 ++-- .../data/index_p0/test_bitmap_index.out | 24 +++++----- .../query_p0/show/test_show_create_table.out | 4 ++ .../rollup/test_materialized_view_hll.out | 14 +++--- ...st_materialized_view_hll_with_light_sc.out | 14 +++--- .../data/rollup_p0/test_materialized_view.out | 48 +++++++++---------- .../data/rollup_p0/test_rollup_agg.out | 18 +++---- .../data/rollup_p0/test_rollup_agg_date.out | 34 ++++++------- .../show/test_show_create_table.groovy | 44 +++++++++++++++++ 14 files changed, 200 insertions(+), 115 deletions(-) create mode 100644 regression-test/data/query_p0/show/test_show_create_table.out create mode 100644 regression-test/suites/query_p0/show/test_show_create_table.groovy diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/DescribeStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/DescribeStmt.java index c9e6c9791c4f76..f3986a8ff86abb 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DescribeStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/DescribeStmt.java @@ -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("ColumnType", ScalarType.createVarchar(20))) .addColumn(new Column("Null", ScalarType.createVarchar(10))) .addColumn(new Column("Key", ScalarType.createVarchar(10))) .addColumn(new Column("Default", ScalarType.createVarchar(30))) @@ -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; @@ -205,6 +211,7 @@ public void analyze(Analyzer analyzer) throws UserException { "", column.getName(), column.getOriginType().toString(), + column.getOriginType().toString(), column.isAllowNull() ? "Yes" : "No", ((Boolean) column.isKey()).toString(), column.getDefaultValue() == null @@ -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()); @@ -288,6 +301,13 @@ public List> getResultRows() throws AnalysisException { List> rows = node.fetchResult().getRows(); List> res = new ArrayList<>(); for (List row : rows) { + // show DATEV2/DATETIMEV2 to DATE/DATETIME for compatibility + if (row.get(1).length() >= 6 && row.get(1).substring(0, 6).equals("DATEV2")) { + row.set(1, "DATE"); + } + if (row.get(1).length() >= 10 && row.get(1).substring(0, 10).equals("DATETIMEV2")) { + row.set(1, "DATETIME"); + } try { Env.getCurrentEnv().getAccessManager() .checkColumnsPriv(ConnectContext.get().getCurrentUserIdentity(), dbTableName.getCtl(), diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java index 790d16e7f030e0..88f8fc279fb9be 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java @@ -633,14 +633,30 @@ public List 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()); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java index 579bc51677ad21..11c6eb5ffed825 100755 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java @@ -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()); } diff --git a/regression-test/data/bloom_filter_p0/test_create_table_with_bloom_filter.out b/regression-test/data/bloom_filter_p0/test_create_table_with_bloom_filter.out index 9d60ceb4676eb9..8e222a38250fe2 100644 --- a/regression-test/data/bloom_filter_p0/test_create_table_with_bloom_filter.out +++ b/regression-test/data/bloom_filter_p0/test_create_table_with_bloom_filter.out @@ -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 @@ -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 diff --git a/regression-test/data/data_model_p0/aggregate/test_aggregate_table.out b/regression-test/data/data_model_p0/aggregate/test_aggregate_table.out index a452023ffb340c..eac6262f1da174 100644 --- a/regression-test/data/data_model_p0/aggregate/test_aggregate_table.out +++ b/regression-test/data/data_model_p0/aggregate/test_aggregate_table.out @@ -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 diff --git a/regression-test/data/data_model_p0/duplicate/test_duplicate_table.out b/regression-test/data/data_model_p0/duplicate/test_duplicate_table.out index 53ca0ae627924c..59973fcdd75026 100644 --- a/regression-test/data/data_model_p0/duplicate/test_duplicate_table.out +++ b/regression-test/data/data_model_p0/duplicate/test_duplicate_table.out @@ -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 diff --git a/regression-test/data/index_p0/test_bitmap_index.out b/regression-test/data/index_p0/test_bitmap_index.out index 8b6081fc7a4af3..5eb7f08b93c869 100644 --- a/regression-test/data/index_p0/test_bitmap_index.out +++ b/regression-test/data/index_p0/test_bitmap_index.out @@ -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 @@ -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 -- @@ -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 -- diff --git a/regression-test/data/query_p0/show/test_show_create_table.out b/regression-test/data/query_p0/show/test_show_create_table.out new file mode 100644 index 00000000000000..cc64b17c40a846 --- /dev/null +++ b/regression-test/data/query_p0/show/test_show_create_table.out @@ -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); + diff --git a/regression-test/data/rollup/test_materialized_view_hll.out b/regression-test/data/rollup/test_materialized_view_hll.out index 26dbbea0ecf418..bc327f78d36e44 100644 --- a/regression-test/data/rollup/test_materialized_view_hll.out +++ b/regression-test/data/rollup/test_materialized_view_hll.out @@ -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 +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 Yes true \N true `store_id` - mva_HLL_UNION__hll_hash(`sale_amt`) HLL No false \N HLL_UNION true hll_hash(`sale_amt`) +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 diff --git a/regression-test/data/rollup/test_materialized_view_hll_with_light_sc.out b/regression-test/data/rollup/test_materialized_view_hll_with_light_sc.out index 84e4aaa6308e19..7ccdc52dad750b 100644 --- a/regression-test/data/rollup/test_materialized_view_hll_with_light_sc.out +++ b/regression-test/data/rollup/test_materialized_view_hll_with_light_sc.out @@ -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 +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 Yes true \N true `store_id` - mva_HLL_UNION__hll_hash(`sale_amt`) HLL No false \N HLL_UNION true hll_hash(`sale_amt`) +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 diff --git a/regression-test/data/rollup_p0/test_materialized_view.out b/regression-test/data/rollup_p0/test_materialized_view.out index 7a5174bb6f3c92..77b5eec90368bc 100644 --- a/regression-test/data/rollup_p0/test_materialized_view.out +++ b/regression-test/data/rollup_p0/test_materialized_view.out @@ -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 +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 Yes true \N true `store_id` - mva_SUM__`sale_amt` BIGINT Yes false \N SUM true `sale_amt` +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 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 +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 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` +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 @@ -37,15 +37,15 @@ seller_id_order DUP_KEYS mv_store_id INT Yes true \N true `store_id` -- !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 diff --git a/regression-test/data/rollup_p0/test_rollup_agg.out b/regression-test/data/rollup_p0/test_rollup_agg.out index d416e8990bf70c..4b6cf40fa44a37 100644 --- a/regression-test/data/rollup_p0/test_rollup_agg.out +++ b/regression-test/data/rollup_p0/test_rollup_agg.out @@ -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 +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 No true \N true - pv BIGINT No false 0 SUM true - vv 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 diff --git a/regression-test/data/rollup_p0/test_rollup_agg_date.out b/regression-test/data/rollup_p0/test_rollup_agg_date.out index 58b2568e5e7d91..970f5dd2f427b1 100644 --- a/regression-test/data/rollup_p0/test_rollup_agg_date.out +++ b/regression-test/data/rollup_p0/test_rollup_agg_date.out @@ -1,23 +1,23 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !sql -- -test_rollup_agg_date AGG_KEYS datek1 DATEV2 Yes true \N true - datetimek1 DATETIMEV2(0) Yes true \N true - datetimek2 DATETIMEV2(3) Yes true \N true - datetimek3 DATETIMEV2(6) Yes true \N true - datev1 DATEV2 No false \N MAX true - datetimev1 DATETIMEV2(0) No false \N MAX true - datetimev2 DATETIMEV2(3) No false \N MAX true - datetimev3 DATETIMEV2(6) No false \N MAX true - datetimev4 DATETIMEV2(3) Yes false \N MAX true +test_rollup_agg_date AGG_KEYS datek1 DATE DATEV2 Yes true \N true + datetimek1 DATETIME DATETIMEV2(0) Yes true \N true + datetimek2 DATETIME DATETIMEV2(3) Yes true \N true + datetimek3 DATETIME DATETIMEV2(6) Yes true \N true + datev1 DATE DATEV2 No false \N MAX true + datetimev1 DATETIME DATETIMEV2(0) No false \N MAX true + datetimev2 DATETIME DATETIMEV2(3) No false \N MAX true + datetimev3 DATETIME DATETIMEV2(6) No false \N MAX true + datetimev4 DATETIME DATETIMEV2(3) Yes false \N MAX true -rollup_date AGG_KEYS datek1 DATEV2 Yes true \N true - datetimek2 DATETIMEV2(3) Yes true \N true - datetimek1 DATETIMEV2(0) Yes true \N true - datetimek3 DATETIMEV2(6) Yes true \N true - datev1 DATEV2 No false \N MAX true - datetimev1 DATETIMEV2(0) No false \N MAX true - datetimev2 DATETIMEV2(3) No false \N MAX true - datetimev3 DATETIMEV2(6) No false \N MAX true +rollup_date AGG_KEYS datek1 DATE DATEV2 Yes true \N true + datetimek2 DATETIME DATETIMEV2(3) Yes true \N true + datetimek1 DATETIME DATETIMEV2(0) Yes true \N true + datetimek3 DATETIME DATETIMEV2(6) Yes true \N true + datev1 DATE DATEV2 No false \N MAX true + datetimev1 DATETIME DATETIMEV2(0) No false \N MAX true + datetimev2 DATETIME DATETIMEV2(3) No false \N MAX true + datetimev3 DATETIME DATETIMEV2(6) No false \N MAX true -- !sql -- 2022-08-23 2022-08-23T11:11:11 2022-08-23T11:11:11.111 2022-08-23T11:11:11.111111 2022-08-23 2022-08-23T11:11:11 2022-08-23T11:11:11.111 2022-08-23T11:11:11.111111 diff --git a/regression-test/suites/query_p0/show/test_show_create_table.groovy b/regression-test/suites/query_p0/show/test_show_create_table.groovy new file mode 100644 index 00000000000000..e2c81ce67e96cb --- /dev/null +++ b/regression-test/suites/query_p0/show/test_show_create_table.groovy @@ -0,0 +1,44 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("test_show_create_table", "query") { + String tb_name = "tb_show_create_table"; + try { + sql """drop table if exists ${tb_name} """ + sql """ + CREATE TABLE IF NOT EXISTS ${tb_name}( + datek1 datev2 COMMENT "a", + datetimek1 datetimev2 COMMENT "b", + datetimek2 datetimev2(3) COMMENT "c", + datetimek3 datetimev2(6) COMMENT "d", + datev1 datev2 MAX NOT NULL COMMENT "e", + datetimev1 datetimev2 MAX NOT NULL COMMENT "f", + datetimev2 datetimev2(3) MAX NOT NULL COMMENT "g", + datetimev3 datetimev2(6) MAX NOT NULL COMMENT "h" + ) + AGGREGATE KEY (datek1, datetimek1, datetimek2, datetimek3) + DISTRIBUTED BY HASH(datek1) BUCKETS 5 properties("replication_num" = "1"); + """ + + qt_select "show create table `${tb_name}`" + + } finally { + + try_sql("DROP TABLE IF EXISTS `${tb_name}`") + } + +} From f92b1a6326056dbb463f7777ae6bf8f3cf5e7f2b Mon Sep 17 00:00:00 2001 From: Cai-Yao <729673078@qq.com> Date: Sat, 8 Apr 2023 19:14:48 +0800 Subject: [PATCH 2/2] show dateV2/datetimeV2 to date/datetime --- .../java/org/apache/doris/analysis/DescribeStmt.java | 9 +-------- .../apache/doris/common/proc/IndexSchemaProcNode.java | 7 +++++++ .../data/rollup/test_materialized_view_hll.out | 2 +- .../rollup/test_materialized_view_hll_with_light_sc.out | 2 +- .../data/rollup_p0/test_materialized_view.out | 8 ++++---- regression-test/data/rollup_p0/test_rollup_agg.out | 2 +- regression-test/data/rollup_p0/test_rollup_agg_date.out | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/DescribeStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/DescribeStmt.java index f3986a8ff86abb..b94fe15d96738d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DescribeStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/DescribeStmt.java @@ -67,7 +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("ColumnType", 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))) @@ -301,13 +301,6 @@ public List> getResultRows() throws AnalysisException { List> rows = node.fetchResult().getRows(); List> res = new ArrayList<>(); for (List row : rows) { - // show DATEV2/DATETIMEV2 to DATE/DATETIME for compatibility - if (row.get(1).length() >= 6 && row.get(1).substring(0, 6).equals("DATEV2")) { - row.set(1, "DATE"); - } - if (row.get(1).length() >= 10 && row.get(1).substring(0, 10).equals("DATETIMEV2")) { - row.set(1, "DATETIME"); - } try { Env.getCurrentEnv().getAccessManager() .checkColumnsPriv(ConnectContext.get().getCurrentUserIdentity(), dbTableName.getCtl(), diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/proc/IndexSchemaProcNode.java b/fe/fe-core/src/main/java/org/apache/doris/common/proc/IndexSchemaProcNode.java index b6b92f9f892238..5824ff36654513 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/proc/IndexSchemaProcNode.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/proc/IndexSchemaProcNode.java @@ -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; diff --git a/regression-test/data/rollup/test_materialized_view_hll.out b/regression-test/data/rollup/test_materialized_view_hll.out index bc327f78d36e44..3924908a1ed8fb 100644 --- a/regression-test/data/rollup/test_materialized_view_hll.out +++ b/regression-test/data/rollup/test_materialized_view_hll.out @@ -5,7 +5,7 @@ test_materialized_view_hll DUP_KEYS record_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`) diff --git a/regression-test/data/rollup/test_materialized_view_hll_with_light_sc.out b/regression-test/data/rollup/test_materialized_view_hll_with_light_sc.out index 7ccdc52dad750b..0303db0d3e3cbe 100644 --- a/regression-test/data/rollup/test_materialized_view_hll_with_light_sc.out +++ b/regression-test/data/rollup/test_materialized_view_hll_with_light_sc.out @@ -5,7 +5,7 @@ test_materialized_view_hll_with_light_sc DUP_KEYS record_id INT INT Yes true \N 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`) diff --git a/regression-test/data/rollup_p0/test_materialized_view.out b/regression-test/data/rollup_p0/test_materialized_view.out index 77b5eec90368bc..0806c2f7f1ea2d 100644 --- a/regression-test/data/rollup_p0/test_materialized_view.out +++ b/regression-test/data/rollup_p0/test_materialized_view.out @@ -5,7 +5,7 @@ test_materialized_view1 DUP_KEYS record_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` @@ -15,7 +15,7 @@ test_materialized_view2 DUP_KEYS record_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` @@ -35,8 +35,8 @@ seller_id_order DUP_KEYS mv_store_id INT INT Yes true \N true `store_id` 1 200 -- !sql -- - - + + 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 diff --git a/regression-test/data/rollup_p0/test_rollup_agg.out b/regression-test/data/rollup_p0/test_rollup_agg.out index 4b6cf40fa44a37..8cdb01eb75c14e 100644 --- a/regression-test/data/rollup_p0/test_rollup_agg.out +++ b/regression-test/data/rollup_p0/test_rollup_agg.out @@ -6,7 +6,7 @@ test_rollup_agg AGG_KEYS siteid INT INT 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 diff --git a/regression-test/data/rollup_p0/test_rollup_agg_date.out b/regression-test/data/rollup_p0/test_rollup_agg_date.out index 970f5dd2f427b1..d29e0742906f71 100644 --- a/regression-test/data/rollup_p0/test_rollup_agg_date.out +++ b/regression-test/data/rollup_p0/test_rollup_agg_date.out @@ -9,7 +9,7 @@ test_rollup_agg_date AGG_KEYS datek1 DATE DATEV2 Yes true \N true datetimev2 DATETIME DATETIMEV2(3) No false \N MAX true datetimev3 DATETIME DATETIMEV2(6) No false \N MAX true datetimev4 DATETIME DATETIMEV2(3) Yes false \N MAX true - + rollup_date AGG_KEYS datek1 DATE DATEV2 Yes true \N true datetimek2 DATETIME DATETIMEV2(3) Yes true \N true datetimek1 DATETIME DATETIMEV2(0) Yes true \N true