From ba75f3457cda1364d626d2eb104393e17e2f038a Mon Sep 17 00:00:00 2001 From: morrySnow <101034200+morrySnow@users.noreply.github.com> Date: Wed, 25 Oct 2023 13:49:27 +0800 Subject: [PATCH] [opt](Nereids) update first_value and last_value signature (#25790) --- .../functions/window/FirstOrLastValue.java | 18 +++----- .../function/test_not_supported_agg_fn.groovy | 42 ------------------- 2 files changed, 6 insertions(+), 54 deletions(-) delete mode 100644 regression-test/suites/tpch_sf0.1_p1/function/test_not_supported_agg_fn.groovy diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/window/FirstOrLastValue.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/window/FirstOrLastValue.java index 44bcf40ec3..0cbccad58d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/window/FirstOrLastValue.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/window/FirstOrLastValue.java @@ -19,28 +19,22 @@ package org.apache.doris.nereids.trees.expressions.functions.window; import org.apache.doris.catalog.FunctionSignature; import org.apache.doris.nereids.trees.expressions.Expression; -import org.apache.doris.nereids.trees.expressions.functions.IdenticalSignature; +import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable; import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression; +import org.apache.doris.nereids.types.coercion.AnyDataType; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; import java.util.List; /** parent class for first_value() and last_value() */ public abstract class FirstOrLastValue extends WindowFunction - implements UnaryExpression, PropagateNullable, IdenticalSignature, RequireTrivialTypes { + implements UnaryExpression, PropagateNullable, ExplicitlyCastableSignature { - static { - List signatures = Lists.newArrayList(); - trivialTypes.forEach(t -> - signatures.add(FunctionSignature.ret(t).args(t)) - ); - SIGNATURES = ImmutableList.copyOf(signatures); - } - - private static final List SIGNATURES; + private static final List SIGNATURES = ImmutableList.of( + FunctionSignature.retArgType(0).args(AnyDataType.INSTANCE_WITHOUT_INDEX) + ); public FirstOrLastValue(String name, Expression child) { super(name, child); diff --git a/regression-test/suites/tpch_sf0.1_p1/function/test_not_supported_agg_fn.groovy b/regression-test/suites/tpch_sf0.1_p1/function/test_not_supported_agg_fn.groovy deleted file mode 100644 index 5be66d7a6f..0000000000 --- a/regression-test/suites/tpch_sf0.1_p1/function/test_not_supported_agg_fn.groovy +++ /dev/null @@ -1,42 +0,0 @@ -// 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. - -// There once exists a bug that when passing a too long string -// along with an empty one to find_in_set, BE - -suite("test_not_supported_agg_fn") { - - try { - test { - sql """ - SELECT ref_0.`PS_SUPPKEY` AS c0, - ref_0.`PS_SUPPLYCOST` AS c1, - last_value(cast(bitmap_empty() AS BITMAP)) OVER (PARTITION BY ref_0.`PS_AVAILQTY` - ORDER BY ref_0.`PS_PARTKEY` DESC) AS c2, - CASE - WHEN FALSE THEN ref_0.`PS_COMMENT` - ELSE ref_0.`PS_COMMENT` - END AS c3 - FROM regression_test_tpch_sf0_1_p1.partsupp AS ref_0 - WHERE ref_0.`PS_PARTKEY` IS NULL - ORDER BY ref_0.`PS_COMMENT` - """ - exception "errCode = 2, detailMessage = No matching function with signature: last_value(bitmap)" - } - } finally { - } -} \ No newline at end of file