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 315b30c23d [testcase](union) add test case for union of decimal 
(#20080)
315b30c23d is described below

commit 315b30c23dcf81d1711d6c15b53bf2789867aaaf
Author: TengJianPing <18241664+jackte...@users.noreply.github.com>
AuthorDate: Fri May 26 14:12:14 2023 +0800

    [testcase](union) add test case for union of decimal (#20080)
---
 .../data/query_p0/union/test_union_decimal_agg.out |  7 ++
 .../query_p0/union/test_union_decimal_agg.groovy   | 85 ++++++++++++++++++++++
 2 files changed, 92 insertions(+)

diff --git a/regression-test/data/query_p0/union/test_union_decimal_agg.out 
b/regression-test/data/query_p0/union/test_union_decimal_agg.out
new file mode 100644
index 0000000000..03e0644755
--- /dev/null
+++ b/regression-test/data/query_p0/union/test_union_decimal_agg.out
@@ -0,0 +1,7 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !decimal_union_agg1 --
+4.8071153846153845
+
+-- !decimal_union_agg2 --
+4.8071153846153845
+
diff --git 
a/regression-test/suites/query_p0/union/test_union_decimal_agg.groovy 
b/regression-test/suites/query_p0/union/test_union_decimal_agg.groovy
new file mode 100644
index 0000000000..c3ab4eec39
--- /dev/null
+++ b/regression-test/suites/query_p0/union/test_union_decimal_agg.groovy
@@ -0,0 +1,85 @@
+// 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_union_decimal_agg") {
+    def db = "test_query_db"
+    sql "use ${db}"
+    
+    sql """ DROP TABLE IF EXISTS `test_union_decimal_agg_1` """
+    sql """ CREATE TABLE `test_union_decimal_agg_1` (
+        `cost` decimalv3(27, 2) NULL,
+        `active` bigint(20) NULL
+    ) ENGINE=OLAP
+    DUPLICATE KEY(`cost`, `active`)
+    DISTRIBUTED BY HASH(`cost`) BUCKETS 10
+    PROPERTIES (
+    "replication_allocation" = "tag.location.default: 1"
+    );
+    """
+
+    sql """ DROP TABLE IF EXISTS `test_union_decimal_agg_2` """
+    sql """ CREATE TABLE `test_union_decimal_agg_2` (
+      `cost` bigint(20) NULL,
+      `activated_count` bigint(20) NULL
+    ) ENGINE=OLAP
+    DUPLICATE KEY(`cost`, `activated_count`)
+    DISTRIBUTED BY HASH(`cost`) BUCKETS 10
+    PROPERTIES (
+    "replication_allocation" = "tag.location.default: 1"
+    );
+    """
+
+    sql """ DROP TABLE IF EXISTS `test_union_decimal_agg_3` """
+    sql """ CREATE TABLE `test_union_decimal_agg_3` (
+      `cost` decimalv3(27, 2) NULL,
+      `ocpcconversionsdetail4` decimalv3(27, 2) NULL
+    ) ENGINE=OLAP
+    DUPLICATE KEY(`cost`, `ocpcconversionsdetail4`)
+    DISTRIBUTED BY HASH(`cost`) BUCKETS 10
+    PROPERTIES (
+    "replication_allocation" = "tag.location.default: 1"
+    );
+    """
+
+    sql """ insert into test_union_decimal_agg_1 values(0, 3); """
+    sql """ insert into test_union_decimal_agg_1 values(0, 4); """
+    sql """ insert into test_union_decimal_agg_1 values(249.97, 45); """
+
+    qt_decimal_union_agg1 """ SELECT
+        sum(basic_data.cost)  / sum(basic_data.active)
+    FROM
+            ( 
+                SELECT cost, active FROM test_union_decimal_agg_1
+             UNION ALL      
+                SELECT cost  / 100.0  AS cost,activated_count as active FROM 
test_union_decimal_agg_2
+            UNION ALL
+                SELECT cast(cost as decimalv3(38, 2)) AS cost,  
ocpcconversionsdetail4  AS active FROM  test_union_decimal_agg_3
+            ) AS `basic_data`;
+    """
+
+    qt_decimal_union_agg2 """ SELECT
+        sum(basic_data.cost)  / sum(basic_data.active)
+    FROM
+            ( 
+                SELECT cost, active FROM test_union_decimal_agg_1
+             UNION ALL      
+                SELECT cost  / 100  AS cost,activated_count as active FROM 
test_union_decimal_agg_2
+            UNION ALL
+                SELECT cast(cost as decimalv3(38, 2)) AS cost,  
ocpcconversionsdetail4  AS active FROM  test_union_decimal_agg_3
+            ) AS `basic_data`;
+    """
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to