You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2022/05/03 14:37:12 UTC

[incubator-doris] branch master updated: [fix](function) handle merge in window_funnel_init and add test (#9338)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new eed62695e1 [fix](function) handle merge in window_funnel_init and add test (#9338)
eed62695e1 is described below

commit eed62695e1a4827c491f685ac41d41e35945bc99
Author: dataroaring <98...@users.noreply.github.com>
AuthorDate: Tue May 3 22:37:06 2022 +0800

    [fix](function) handle merge in window_funnel_init and add test (#9338)
---
 be/src/exprs/aggregate_functions.cpp               |  7 +--
 .../data/query/aggregate/window_funnel.out         |  7 +++
 .../suites/query/aggregate/window_funnel.groovy    | 63 ++++++++++++++++++++++
 3 files changed, 74 insertions(+), 3 deletions(-)

diff --git a/be/src/exprs/aggregate_functions.cpp b/be/src/exprs/aggregate_functions.cpp
index dbd1b1c818..590e07838a 100644
--- a/be/src/exprs/aggregate_functions.cpp
+++ b/be/src/exprs/aggregate_functions.cpp
@@ -2500,9 +2500,10 @@ void AggregateFunctions::window_funnel_init(FunctionContext* ctx, StringVal* dst
     WindowFunnelState* state = new WindowFunnelState();
     dst->ptr = (uint8_t*)state;
     // constant args at index 0 and 1
-    DCHECK(ctx->is_arg_constant(0));
-    BigIntVal* window = reinterpret_cast<BigIntVal*>(ctx->get_constant_arg(0));
-    state->window = window->val;
+    if (ctx->is_arg_constant(0)) {
+        BigIntVal* window = reinterpret_cast<BigIntVal*>(ctx->get_constant_arg(0));
+        state->window = window->val;
+    }
     // TODO handle mode in the future
 }
 
diff --git a/regression-test/data/query/aggregate/window_funnel.out b/regression-test/data/query/aggregate/window_funnel.out
new file mode 100644
index 0000000000..d830ba5591
--- /dev/null
+++ b/regression-test/data/query/aggregate/window_funnel.out
@@ -0,0 +1,7 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !window_funnel --
+1
+
+-- !window_funnel --
+2
+
diff --git a/regression-test/suites/query/aggregate/window_funnel.groovy b/regression-test/suites/query/aggregate/window_funnel.groovy
new file mode 100644
index 0000000000..279b433b53
--- /dev/null
+++ b/regression-test/suites/query/aggregate/window_funnel.groovy
@@ -0,0 +1,63 @@
+// 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.
+
+// The cases is copied from https://github.com/trinodb/trino/tree/master
+// /testing/trino-product-tests/src/main/resources/sql-tests/testcases/aggregate
+// and modified by Doris.
+
+suite("window_funnel") {
+    def tableName = "windowfunnel_test"
+
+    sql """ DROP TABLE IF EXISTS ${tableName} """
+    sql """
+            CREATE TABLE IF NOT EXISTS ${tableName} (
+                xwho varchar(50) NULL COMMENT 'xwho',
+                xwhen datetime COMMENT 'xwhen',
+                xwhat int NULL COMMENT 'xwhat'
+            )
+            DUPLICATE KEY(xwho)
+            DISTRIBUTED BY HASH(xwho) BUCKETS 3
+            PROPERTIES (
+            "replication_num" = "1"
+            );
+        """
+    sql "INSERT into ${tableName} (xwho, xwhen, xwhat) VALUES('1', '2022-03-12 10:41:00', 1)"
+    sql "INSERT INTO ${tableName} (xwho, xwhen, xwhat) VALUES('1', '2022-03-12 13:28:02', 2)"
+    sql "INSERT INTO ${tableName} (xwho, xwhen, xwhat) VALUES('1', '2022-03-12 16:15:01', 3)"
+    sql "INSERT INTO ${tableName} (xwho, xwhen, xwhat) VALUES('1', '2022-03-12 19:05:04', 4)"
+
+    qt_window_funnel """ select
+                             window_funnel(
+                                1,
+                                'default',
+                                t.xwhen,
+                                t.xwhat = 1,
+                                t.xwhat = 2
+                             ) AS level
+                        from ${tableName} t;
+                 """
+    qt_window_funnel """ select
+                             window_funnel(
+                                20000,
+                                'default',
+                                t.xwhen,
+                                t.xwhat = 1,
+                                t.xwhat = 2
+                             ) AS level
+                        from ${tableName} t;
+                 """
+}


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