This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new b656f31cf2 [Enchancement](compatible) show decimalv3 to decimal 
(#21782)
b656f31cf2 is described below

commit b656f31cf2260685d24ed17b9bee5f94208867a5
Author: Mryange <[email protected]>
AuthorDate: Tue Jul 18 09:17:14 2023 +0800

    [Enchancement](compatible) show decimalv3 to decimal (#21782)
---
 .../org/apache/doris/analysis/DescribeStmt.java    | 22 ++++++++++
 .../main/java/org/apache/doris/catalog/Column.java | 10 +++++
 .../doris/common/proc/IndexSchemaProcNode.java     | 12 ++++++
 .../analysis/CreateTableAsSelectStmtTest.java      |  4 +-
 .../test_create_table_with_bloom_filter.out        | 20 ++++-----
 .../datatype_p0/decimalv3/test_show_decimalv3.out  | 17 ++++++++
 .../data/index_p0/test_bitmap_index.out            |  6 +--
 .../test_decimal_bitmap_index_multi_page.out       |  2 +-
 .../data/inverted_index_p0/test_bitmap_index.out   |  6 +--
 .../data/inverted_index_p0/test_inverted_index.out |  6 +--
 .../decimalv3/test_show_decimalv3.groovy           | 49 ++++++++++++++++++++++
 11 files changed, 132 insertions(+), 22 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 a2ca22a213..f632c00f9c 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
@@ -139,6 +139,17 @@ public class DescribeStmt extends ShowStmt {
                     row.set(1, typeStr.toString());
                 } else if (column.getOriginType().isDateV2()) {
                     row.set(1, "DATE");
+                } else if (column.getOriginType().isDecimalV3()) {
+                    StringBuilder typeStr = new StringBuilder("DECIMAL");
+                    ScalarType sType = (ScalarType) column.getOriginType();
+                    int scale = sType.getScalarScale();
+                    int precision = sType.getScalarPrecision();
+                    // not default
+                    if (scale > 0 && precision != 9) {
+                        typeStr.append("(").append(precision).append(", 
").append(scale)
+                                .append(")");
+                    }
+                    row.set(1, typeStr.toString());
                 }
                 totalRows.add(row);
             }
@@ -235,6 +246,17 @@ public class DescribeStmt extends ShowStmt {
                                 row.set(3, typeStr.toString());
                             } else if (column.getOriginType().isDateV2()) {
                                 row.set(3, "DATE");
+                            } else if (column.getOriginType().isDecimalV3()) {
+                                StringBuilder typeStr = new 
StringBuilder("DECIMAL");
+                                ScalarType sType = (ScalarType) 
column.getOriginType();
+                                int scale = sType.getScalarScale();
+                                int precision = sType.getScalarPrecision();
+                                // not default
+                                if (scale > 0 && precision != 9) {
+                                    
typeStr.append("(").append(precision).append(", ").append(scale)
+                                            .append(")");
+                                }
+                                row.set(3, typeStr.toString());
                             }
 
                             if (j == 0) {
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 d323ae4cc3..bfb26aad40 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
@@ -728,6 +728,16 @@ public class Column implements Writable, 
GsonPostProcessable {
                 }
             } else if (type.isDateV2()) {
                 sb.append("date");
+            } else if (type.isDecimalV3()) {
+                sb.append("DECIMAL");
+                ScalarType sType = (ScalarType) type;
+                int scale = sType.getScalarScale();
+                int precision = sType.getScalarPrecision();
+                // not default
+                if (scale > 0 && precision != 9) {
+                    sb.append("(").append(precision).append(", ").append(scale)
+                            .append(")");
+                }
             } else {
                 sb.append(typeStr);
             }
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 70b31db1e4..47da7a9d53 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
@@ -88,6 +88,18 @@ public class IndexSchemaProcNode implements 
ProcNodeInterface {
                 }
                 rowList.set(1, typeStr.toString());
             }
+            if (column.getOriginType().isDecimalV3()) {
+                StringBuilder typeStr = new StringBuilder("DECIMAL");
+                ScalarType sType = (ScalarType) column.getOriginType();
+                int scale = sType.getScalarScale();
+                int precision = sType.getScalarPrecision();
+                // not default
+                if (scale > 0 && precision != 9) {
+                    typeStr.append("(").append(precision).append(", 
").append(scale)
+                            .append(")");
+                }
+                rowList.set(1, typeStr.toString());
+            }
             result.addRow(rowList);
         }
         return result;
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableAsSelectStmtTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableAsSelectStmtTest.java
index f4102acd39..ae75b8e869 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableAsSelectStmtTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableAsSelectStmtTest.java
@@ -85,7 +85,7 @@ public class CreateTableAsSelectStmtTest extends 
TestWithFeService {
         Assertions.assertEquals("CREATE TABLE `select_decimal_table` (\n"
                         + "  `userId` varchar(65533) NOT NULL,\n"
                         + "  `amount_decimal` "
-                        + (Config.enable_decimal_conversion ? "decimalv3" : 
"decimal") + "(10, 2) NOT NULL\n"
+                        + "DECIMAL" + "(10, 2) NOT NULL\n"
                         + ") ENGINE=OLAP\n"
                         + "DUPLICATE KEY(`userId`)\n"
                         + "COMMENT 'OLAP'\n"
@@ -105,7 +105,7 @@ public class CreateTableAsSelectStmtTest extends 
TestWithFeService {
         if (Config.enable_decimal_conversion) {
             Assertions.assertEquals(
                     "CREATE TABLE `select_decimal_table_1` (\n"
-                            + "  `_col0` decimalv3(38, 2) NULL\n"
+                            + "  `_col0` DECIMAL(38, 2) NULL\n"
                             + ") ENGINE=OLAP\n"
                             + "DUPLICATE KEY(`_col0`)\n"
                             + "COMMENT 'OLAP'\n"
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 eb7280263b..0409ab7fb3 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
@@ -11,11 +11,11 @@ char_50_key CHAR(50)        No      true    \N      
BLOOM_FILTER
 character_key  VARCHAR(500)    No      true    \N      BLOOM_FILTER
 char_key       CHAR(1) No      true    \N      BLOOM_FILTER
 character_most_key     VARCHAR(65533)  No      true    \N      BLOOM_FILTER
-decimal_key    DECIMALV3(20, 6)        No      true    \N      BLOOM_FILTER
-decimal_most_key       DECIMALV3(27, 9)        No      true    \N      
BLOOM_FILTER
-decimal32_key  DECIMALV3(5, 1) No      true    \N      BLOOM_FILTER
-decimal64_key  DECIMALV3(14, 1)        No      true    \N      BLOOM_FILTER
-decimal128_key DECIMALV3(38, 1)        No      true    \N      BLOOM_FILTER
+decimal_key    DECIMAL(20, 6)  No      true    \N      BLOOM_FILTER
+decimal_most_key       DECIMAL(27, 9)  No      true    \N      BLOOM_FILTER
+decimal32_key  DECIMAL(5, 1)   No      true    \N      BLOOM_FILTER
+decimal64_key  DECIMAL(14, 1)  No      true    \N      BLOOM_FILTER
+decimal128_key DECIMAL(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     DATE    No      true    \N      BLOOM_FILTER
@@ -30,11 +30,11 @@ char_50_value       CHAR(50)        No      false   \N      
REPLACE
 character_value        VARCHAR(500)    No      false   \N      REPLACE
 char_value     CHAR(1) No      false   \N      REPLACE
 character_most_value   VARCHAR(65533)  No      false   \N      REPLACE
-decimal_value  DECIMALV3(20, 6)        No      false   \N      SUM
-decimal_most_value     DECIMALV3(27, 9)        No      false   \N      SUM
-decimal32_value        DECIMALV3(5, 1) No      false   \N      SUM
-decimal64_value        DECIMALV3(14, 1)        No      false   \N      SUM
-decimal128_value       DECIMALV3(38, 1)        No      false   \N      SUM
+decimal_value  DECIMAL(20, 6)  No      false   \N      SUM
+decimal_most_value     DECIMAL(27, 9)  No      false   \N      SUM
+decimal32_value        DECIMAL(5, 1)   No      false   \N      SUM
+decimal64_value        DECIMAL(14, 1)  No      false   \N      SUM
+decimal128_value       DECIMAL(38, 1)  No      false   \N      SUM
 date_value_max DATE    No      false   \N      MAX
 date_value_replace     DATE    No      false   \N      REPLACE
 date_value_min DATE    No      false   \N      MIN
diff --git a/regression-test/data/datatype_p0/decimalv3/test_show_decimalv3.out 
b/regression-test/data/datatype_p0/decimalv3/test_show_decimalv3.out
new file mode 100644
index 0000000000..008e485e4b
--- /dev/null
+++ b/regression-test/data/datatype_p0/decimalv3/test_show_decimalv3.out
@@ -0,0 +1,17 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select1 --
+id     INT     No      true    \N      
+dd     DECIMAL(15, 6)  Yes     false   \N      NONE
+
+-- !select2 --
+showdb UNIQUE_KEYS     id      INT     INT     No      true    \N              
true            
+               dd      DECIMAL(15, 6)  DECIMALV3(15, 6)        Yes     false   
\N      NONE    true            
+
+-- !select3 --
+id     INT     No      true    \N      
+dd     DECIMAL Yes     false   \N      NONE
+
+-- !select4 --
+showdb UNIQUE_KEYS     id      INT     INT     No      true    \N              
true            
+               dd      DECIMAL DECIMALV3(9, 0) Yes     false   \N      NONE    
true            
+
diff --git a/regression-test/data/index_p0/test_bitmap_index.out 
b/regression-test/data/index_p0/test_bitmap_index.out
index 1994ffc43f..e490d7a803 100644
--- a/regression-test/data/index_p0/test_bitmap_index.out
+++ b/regression-test/data/index_p0/test_bitmap_index.out
@@ -9,7 +9,7 @@ k6      VARCHAR(1)      Yes     false   \N      NONE
 k7     DATE    Yes     false   \N      NONE
 k8     DATETIME        Yes     false   \N      NONE
 k9     LARGEINT        Yes     false   \N      NONE
-k10    DECIMALV3(9, 0) Yes     false   \N      NONE
+k10    DECIMAL Yes     false   \N      NONE
 k11    BOOLEAN Yes     false   \N      NONE
 k12    DATE    Yes     false   \N      NONE
 k13    DATETIME        Yes     false   \N      NONE
@@ -46,7 +46,7 @@ k6    VARCHAR(1)      Yes     true    \N
 k7     DATE    Yes     true    \N      
 k8     DATETIME        Yes     true    \N      
 k9     LARGEINT        Yes     true    \N      
-k10    DECIMALV3(9, 0) Yes     true    \N      
+k10    DECIMAL Yes     true    \N      
 k11    BOOLEAN Yes     true    \N      
 k12    DATE    Yes     true    \N      
 k13    DATETIME        Yes     true    \N      
@@ -84,7 +84,7 @@ k6    VARCHAR(1)      Yes     true    \N
 k7     DATE    Yes     true    \N      
 k8     DATETIME        Yes     true    \N      
 k9     LARGEINT        Yes     true    \N      
-k10    DECIMALV3(9, 0) Yes     true    \N      
+k10    DECIMAL Yes     true    \N      
 k11    BOOLEAN Yes     true    \N      
 k12    DATE    Yes     false   \N      REPLACE
 k13    DATETIME        Yes     false   \N      REPLACE
diff --git 
a/regression-test/data/index_p0/test_decimal_bitmap_index_multi_page.out 
b/regression-test/data/index_p0/test_decimal_bitmap_index_multi_page.out
index 623f1d897e..f9bb51cd8a 100644
--- a/regression-test/data/index_p0/test_decimal_bitmap_index_multi_page.out
+++ b/regression-test/data/index_p0/test_decimal_bitmap_index_multi_page.out
@@ -1,6 +1,6 @@
 -- This file is automatically generated. You should know what you did if you 
want to edit this
 -- !sql --
-a      DECIMALV3(12, 6)        No      true    \N      
+a      DECIMAL(12, 6)  No      true    \N      
 
 -- !sql --
 default_cluster:regression_test_index_p0.test_decimal_bitmap_index_multi_page  
        bitmap_index_multi_page         a                                       
        BITMAP          
diff --git a/regression-test/data/inverted_index_p0/test_bitmap_index.out 
b/regression-test/data/inverted_index_p0/test_bitmap_index.out
index e03cc9f29e..12e4475c96 100644
--- a/regression-test/data/inverted_index_p0/test_bitmap_index.out
+++ b/regression-test/data/inverted_index_p0/test_bitmap_index.out
@@ -9,7 +9,7 @@ k6      VARCHAR(1)      Yes     false   \N      NONE
 k7     DATE    Yes     false   \N      NONE
 k8     DATETIME        Yes     false   \N      NONE
 k9     LARGEINT        Yes     false   \N      NONE
-k10    DECIMALV3(9, 0) Yes     false   \N      NONE
+k10    DECIMAL Yes     false   \N      NONE
 k11    BOOLEAN Yes     false   \N      NONE
 
 -- !sql --
@@ -38,7 +38,7 @@ k6    VARCHAR(1)      Yes     true    \N
 k7     DATE    Yes     true    \N      
 k8     DATETIME        Yes     true    \N      
 k9     LARGEINT        Yes     true    \N      
-k10    DECIMALV3(9, 0) Yes     true    \N      
+k10    DECIMAL Yes     true    \N      
 k11    BOOLEAN Yes     true    \N      
 v1     INT     Yes     false   \N      SUM
 
@@ -68,7 +68,7 @@ k6    VARCHAR(1)      Yes     true    \N
 k7     DATE    Yes     true    \N      
 k8     DATETIME        Yes     true    \N      
 k9     LARGEINT        Yes     true    \N      
-k10    DECIMALV3(9, 0) Yes     true    \N      
+k10    DECIMAL Yes     true    \N      
 k11    BOOLEAN Yes     true    \N      
 v1     INT     Yes     false   \N      REPLACE
 
diff --git a/regression-test/data/inverted_index_p0/test_inverted_index.out 
b/regression-test/data/inverted_index_p0/test_inverted_index.out
index 82b525127f..f501b1e48d 100644
--- a/regression-test/data/inverted_index_p0/test_inverted_index.out
+++ b/regression-test/data/inverted_index_p0/test_inverted_index.out
@@ -9,7 +9,7 @@ k6      VARCHAR(1)      Yes     false   \N      NONE
 k7     DATE    Yes     false   \N      NONE
 k8     DATETIME        Yes     false   \N      NONE
 k9     LARGEINT        Yes     false   \N      NONE
-k10    DECIMALV3(9, 0) Yes     false   \N      NONE
+k10    DECIMAL Yes     false   \N      NONE
 k11    BOOLEAN Yes     false   \N      NONE
 k12    DATE    Yes     false   \N      NONE
 k13    DATETIME        Yes     false   \N      NONE
@@ -46,7 +46,7 @@ k6    VARCHAR(1)      Yes     true    \N
 k7     DATE    Yes     true    \N      
 k8     DATETIME        Yes     true    \N      
 k9     LARGEINT        Yes     true    \N      
-k10    DECIMALV3(9, 0) Yes     true    \N      
+k10    DECIMAL Yes     true    \N      
 k11    BOOLEAN Yes     true    \N      
 k12    DATE    Yes     true    \N      
 k13    DATETIME        Yes     true    \N      
@@ -84,7 +84,7 @@ k6    VARCHAR(1)      Yes     true    \N
 k7     DATE    Yes     true    \N      
 k8     DATETIME        Yes     true    \N      
 k9     LARGEINT        Yes     true    \N      
-k10    DECIMALV3(9, 0) Yes     true    \N      
+k10    DECIMAL Yes     true    \N      
 k11    BOOLEAN Yes     true    \N      
 k12    DATE    Yes     false   \N      NONE
 k13    DATETIME        Yes     false   \N      NONE
diff --git 
a/regression-test/suites/datatype_p0/decimalv3/test_show_decimalv3.groovy 
b/regression-test/suites/datatype_p0/decimalv3/test_show_decimalv3.groovy
new file mode 100644
index 0000000000..100e7b5e58
--- /dev/null
+++ b/regression-test/suites/datatype_p0/decimalv3/test_show_decimalv3.groovy
@@ -0,0 +1,49 @@
+// 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_decimalv3") {
+    sql """DROP TABLE IF EXISTS showdb """
+    sql """
+        CREATE TABLE IF NOT EXISTS showdb (
+            `id` int(11) NOT NULL ,
+            `dd` decimal(15,6)
+        )
+        UNIQUE KEY(`id`)
+        DISTRIBUTED BY HASH(`id`) BUCKETS 10
+        PROPERTIES (
+        "enable_unique_key_merge_on_write" = "true",
+        "replication_num" = "1")
+    """
+    qt_select1 """desc showdb"""
+    qt_select2 """desc showdb all"""
+
+    sql """DROP TABLE IF EXISTS showdb """
+    sql """
+        CREATE TABLE IF NOT EXISTS showdb (
+            `id` int(11) NOT NULL ,
+            `dd` decimal
+        )
+        UNIQUE KEY(`id`)
+        DISTRIBUTED BY HASH(`id`) BUCKETS 10
+        PROPERTIES (
+        "enable_unique_key_merge_on_write" = "true",
+        "replication_num" = "1")
+    """
+    qt_select3 """desc showdb"""
+    qt_select4 """desc showdb all"""
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to