From 5e9c0c350036ff3e609e64d3941ff75012dd80c8 Mon Sep 17 00:00:00 2001 From: WenYao <729673078@qq.com> Date: Fri, 28 Apr 2023 11:31:51 +0800 Subject: [PATCH] [Enhancement](data-type) add FE config to prohibit create date and decimalv2 type (#19077) * prohibits date and decimal type * add config in test --- .../docs/sql-manual/sql-reference/Data-Types/DATE.md | 2 ++ .../sql-manual/sql-reference/Data-Types/DECIMAL.md | 3 +++ .../docs/sql-manual/sql-reference/Data-Types/DATE.md | 1 + .../sql-manual/sql-reference/Data-Types/DECIMAL.md | 3 +++ .../main/java/org/apache/doris/common/Config.java | 12 ++++++++++++ .../org/apache/doris/analysis/CreateTableStmt.java | 7 +++++++ .../org/apache/doris/utframe/TestWithFeService.java | 2 ++ .../java/org/apache/doris/utframe/UtFrameUtils.java | 2 ++ regression-test/pipeline/p0/conf/fe.conf | 2 ++ regression-test/pipeline/p1/conf/fe.conf | 2 ++ 10 files changed, 36 insertions(+) diff --git a/docs/en/docs/sql-manual/sql-reference/Data-Types/DATE.md b/docs/en/docs/sql-manual/sql-reference/Data-Types/DATE.md index 5b2f29499f..83869ef94f 100644 --- a/docs/en/docs/sql-manual/sql-reference/Data-Types/DATE.md +++ b/docs/en/docs/sql-manual/sql-reference/Data-Types/DATE.md @@ -37,6 +37,8 @@ Date type, the current range of values is ['0000-01-01','9999-12-31'], and the d ### note If you use version 1.2 and above, it is strongly recommended that you use the DATEV2 type instead of the DATE type as DATEV2 is more efficient than DATE type。 +We intend to delete this type in 2024. At this stage, Doris prohibits creating tables containing the `DATE` type by default. If you need to use it, you need to add `disable_datev1 = false` in the FE's config and restart the FE. + ### example ``` SELECT DATE('2003-12-31 01:02:03'); diff --git a/docs/en/docs/sql-manual/sql-reference/Data-Types/DECIMAL.md b/docs/en/docs/sql-manual/sql-reference/Data-Types/DECIMAL.md index 450285d4cc..a9e6ff8564 100644 --- a/docs/en/docs/sql-manual/sql-reference/Data-Types/DECIMAL.md +++ b/docs/en/docs/sql-manual/sql-reference/Data-Types/DECIMAL.md @@ -35,5 +35,8 @@ in addition, M must be greater than or equal to the value of D. The default value is DECIMAL(9, 0). +### note +We intend to delete this type in 2024. At this stage, Doris prohibits creating tables containing the `DECIMAL` type by default. If you need to use it, you need to add `disable_decimalv2 = false` in the FE's config and restart the FE. + ### keywords DECIMAL diff --git a/docs/zh-CN/docs/sql-manual/sql-reference/Data-Types/DATE.md b/docs/zh-CN/docs/sql-manual/sql-reference/Data-Types/DATE.md index 16dce6bf30..0e9ec71c11 100644 --- a/docs/zh-CN/docs/sql-manual/sql-reference/Data-Types/DATE.md +++ b/docs/zh-CN/docs/sql-manual/sql-reference/Data-Types/DATE.md @@ -35,6 +35,7 @@ under the License. ### note 如果您使用1.2及以上版本,强烈推荐您使用DATEV2类型替代DATE类型。相比DATE类型,DATEV2更加高效。 + 我们打算在2024年删除这个类型,目前阶段,Doris默认禁止创建含有DATE类型的表,如果需要使用需要在FE的config中添加`disable_datev1 = false`,并重启FE。 ### example mysql> SELECT DATE('2003-12-31 01:02:03'); diff --git a/docs/zh-CN/docs/sql-manual/sql-reference/Data-Types/DECIMAL.md b/docs/zh-CN/docs/sql-manual/sql-reference/Data-Types/DECIMAL.md index f59c280fc5..9009f7710b 100644 --- a/docs/zh-CN/docs/sql-manual/sql-reference/Data-Types/DECIMAL.md +++ b/docs/zh-CN/docs/sql-manual/sql-reference/Data-Types/DECIMAL.md @@ -33,5 +33,8 @@ under the License. 默认值为 DECIMAL(9, 0)。 +### note + 我们打算在2024年删除这个类型,目前阶段,Doris默认禁止创建含有DECIMAL类型的表,如果需要使用需要在FE的config中添加`disable_decimalv2 = false`,并重启FE。 + ### keywords DECIMAL diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java index 7c1ed56104..2b40215064 100644 --- a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java +++ b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java @@ -2162,5 +2162,17 @@ public class Config extends ConfigBase { */ @ConfField(mutable = true, masterOnly = true) public static boolean experimental_enable_duplicate_without_keys_by_default = false; + + /** + * To prevent different types (V1, V2, V3) of behavioral inconsistencies, + * we may delete the DecimalV2 and DateV1 types in the future. + * At this stage, we use ‘disable_decimalv2’ and ‘disable_datev1’ + * to determine whether these two types take effect. + */ + @ConfField(mutable = true) + public static boolean disable_decimalv2 = true; + + @ConfField(mutable = true) + public static boolean disable_datev1 = true; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java index 498347a207..4a75fd086e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java @@ -329,6 +329,13 @@ public class CreateTableStmt extends DdlStmt { if (Objects.equals(columnDef.getType(), Type.ALL)) { throw new AnalysisException("Disable to create table with `ALL` type columns."); } + if (Objects.equals(columnDef.getType(), Type.DATE) && Config.disable_datev1) { + throw new AnalysisException("Disable to create table with `DATE` type columns, please use `DATEV2`."); + } + if (Objects.equals(columnDef.getType(), Type.DECIMALV2) && Config.disable_decimalv2) { + throw new AnalysisException("Disable to create table with `DECIMAL` type columns," + + "please use `DECIMALV3`."); + } } // analyze key desc if (engineName.equalsIgnoreCase("olap")) { diff --git a/fe/fe-core/src/test/java/org/apache/doris/utframe/TestWithFeService.java b/fe/fe-core/src/test/java/org/apache/doris/utframe/TestWithFeService.java index 5fa5946e83..c3f5be46cf 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/utframe/TestWithFeService.java +++ b/fe/fe-core/src/test/java/org/apache/doris/utframe/TestWithFeService.java @@ -290,6 +290,8 @@ public abstract class TestWithFeService { Config.plugin_dir = dorisHome + "/plugins"; Config.custom_config_dir = dorisHome + "/conf"; Config.edit_log_type = "local"; + Config.disable_decimalv2 = false; + Config.disable_datev1 = false; File file = new File(Config.custom_config_dir); if (!file.exists()) { file.mkdir(); diff --git a/fe/fe-core/src/test/java/org/apache/doris/utframe/UtFrameUtils.java b/fe/fe-core/src/test/java/org/apache/doris/utframe/UtFrameUtils.java index a14e5319e6..00f5ae313b 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/utframe/UtFrameUtils.java +++ b/fe/fe-core/src/test/java/org/apache/doris/utframe/UtFrameUtils.java @@ -177,6 +177,8 @@ public class UtFrameUtils { Config.plugin_dir = dorisHome + "/plugins"; Config.custom_config_dir = dorisHome + "/conf"; Config.edit_log_type = "local"; + Config.disable_decimalv2 = false; + Config.disable_datev1 = false; File file = new File(Config.custom_config_dir); if (!file.exists()) { file.mkdir(); diff --git a/regression-test/pipeline/p0/conf/fe.conf b/regression-test/pipeline/p0/conf/fe.conf index c11c6fe566..05af3f091d 100644 --- a/regression-test/pipeline/p0/conf/fe.conf +++ b/regression-test/pipeline/p0/conf/fe.conf @@ -42,6 +42,8 @@ sys_log_level = INFO # meta_dir = ${DORIS_HOME}/doris-meta mysql_service_nio_enabled = true +disable_decimalv2 = false +disable_datev1 = false catalog_trash_expire_second=1 # Choose one if there are more than one ip except loopback address. # Note that there should at most one ip match this list. diff --git a/regression-test/pipeline/p1/conf/fe.conf b/regression-test/pipeline/p1/conf/fe.conf index 33d0cd7b25..3e7ba70a6c 100644 --- a/regression-test/pipeline/p1/conf/fe.conf +++ b/regression-test/pipeline/p1/conf/fe.conf @@ -42,6 +42,8 @@ sys_log_level = INFO # meta_dir = ${DORIS_HOME}/doris-meta mysql_service_nio_enabled = true +disable_decimalv2 = false +disable_datev1 = false catalog_trash_expire_second=1 # Choose one if there are more than one ip except loopback address. # Note that there should at most one ip match this list.