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

taiyangli pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git


The following commit(s) were added to refs/heads/main by this push:
     new 11d658ec45 remove least and greatest function (#8091)
11d658ec45 is described below

commit 11d658ec4541fcf2c470c64e745a0c8c79ecfb32
Author: kevinyhzou <[email protected]>
AuthorDate: Tue Dec 3 11:44:49 2024 +0800

    remove least and greatest function (#8091)
---
 .../local-engine/Functions/FunctionGreatestLeast.h | 80 ----------------------
 .../Functions/SparkFunctionGreatest.cpp            | 38 ----------
 .../local-engine/Functions/SparkFunctionLeast.cpp  | 38 ----------
 .../CommonScalarFunctionParser.cpp                 |  4 +-
 .../utils/clickhouse/ClickHouseTestSettings.scala  |  2 -
 .../utils/clickhouse/ClickHouseTestSettings.scala  |  2 -
 .../utils/clickhouse/ClickHouseTestSettings.scala  |  2 -
 .../utils/clickhouse/ClickHouseTestSettings.scala  |  2 -
 8 files changed, 2 insertions(+), 166 deletions(-)

diff --git a/cpp-ch/local-engine/Functions/FunctionGreatestLeast.h 
b/cpp-ch/local-engine/Functions/FunctionGreatestLeast.h
deleted file mode 100644
index e9b66df84e..0000000000
--- a/cpp-ch/local-engine/Functions/FunctionGreatestLeast.h
+++ /dev/null
@@ -1,80 +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.
- */
-#pragma once
-#include <DataTypes/DataTypeNullable.h>
-#include <DataTypes/getLeastSupertype.h>
-#include <Functions/FunctionBinaryArithmetic.h>
-#include <Functions/FunctionFactory.h>
-#include <Functions/LeastGreatestGeneric.h>
-
-namespace DB
-{
-namespace ErrorCodes
-{
-    extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
-}
-}
-namespace local_engine
-{
-template <DB::LeastGreatest kind>
-class FunctionGreatestestLeast : public DB::FunctionLeastGreatestGeneric<kind>
-{
-public:
-    bool useDefaultImplementationForNulls() const override { return false; }
-    virtual String getName() const = 0;
-
-private:
-    DB::DataTypePtr getReturnTypeImpl(const DB::DataTypes & types) const 
override
-    {
-        if (types.empty())
-            throw 
DB::Exception(DB::ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, "Function {} 
cannot be called without arguments", getName());
-        return makeNullable(getLeastSupertype(types));
-    }
-
-    DB::ColumnPtr executeImpl(const DB::ColumnsWithTypeAndName & arguments, 
const DB::DataTypePtr & result_type, size_t input_rows_count) const override
-    {
-        size_t num_arguments = arguments.size();
-        DB::Columns converted_columns(num_arguments);
-        for (size_t arg = 0; arg < num_arguments; ++arg)
-            converted_columns[arg] = castColumn(arguments[arg], 
result_type)->convertToFullColumnIfConst();
-        auto result_column = result_type->createColumn();
-        result_column->reserve(input_rows_count);
-        for (size_t row_num = 0; row_num < input_rows_count; ++row_num)
-        {
-            size_t best_arg = 0;
-            for (size_t arg = 1; arg < num_arguments; ++arg)
-            {
-                if constexpr (kind == DB::LeastGreatest::Greatest)
-                {
-                    auto cmp_result = 
converted_columns[arg]->compareAt(row_num, row_num, 
*converted_columns[best_arg], -1);
-                    if (cmp_result > 0)
-                        best_arg = arg;
-                }
-                else
-                {
-                    auto cmp_result = 
converted_columns[arg]->compareAt(row_num, row_num, 
*converted_columns[best_arg], 1);
-                    if (cmp_result < 0)
-                        best_arg = arg;
-                }
-            }
-            result_column->insertFrom(*converted_columns[best_arg], row_num);
-        }
-        return result_column;
-    }
-};
-
-}
diff --git a/cpp-ch/local-engine/Functions/SparkFunctionGreatest.cpp 
b/cpp-ch/local-engine/Functions/SparkFunctionGreatest.cpp
deleted file mode 100644
index 920fe1b9c9..0000000000
--- a/cpp-ch/local-engine/Functions/SparkFunctionGreatest.cpp
+++ /dev/null
@@ -1,38 +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.
- */
-#include <Functions/FunctionGreatestLeast.h>
-
-namespace local_engine
-{
-class SparkFunctionGreatest : public 
FunctionGreatestestLeast<DB::LeastGreatest::Greatest>
-{
-public:
-    static constexpr auto name = "sparkGreatest";
-    static DB::FunctionPtr create(DB::ContextPtr) { return 
std::make_shared<SparkFunctionGreatest>(); }
-    SparkFunctionGreatest() = default;
-    ~SparkFunctionGreatest() override = default;
-    String getName() const override
-    {
-        return name;
-    } 
-};
-
-REGISTER_FUNCTION(SparkGreatest)
-{
-    factory.registerFunction<SparkFunctionGreatest>();
-}
-}
diff --git a/cpp-ch/local-engine/Functions/SparkFunctionLeast.cpp 
b/cpp-ch/local-engine/Functions/SparkFunctionLeast.cpp
deleted file mode 100644
index 70aafdf072..0000000000
--- a/cpp-ch/local-engine/Functions/SparkFunctionLeast.cpp
+++ /dev/null
@@ -1,38 +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.
- */
-#include <Functions/FunctionGreatestLeast.h>
-
-namespace local_engine
-{
-class SparkFunctionLeast : public 
FunctionGreatestestLeast<DB::LeastGreatest::Least>
-{
-public:
-    static constexpr auto name = "sparkLeast";
-    static DB::FunctionPtr create(DB::ContextPtr) { return 
std::make_shared<SparkFunctionLeast>(); }
-    SparkFunctionLeast() = default;
-    ~SparkFunctionLeast() override = default;
-    String getName() const override
-    {
-        return name;
-    } 
-};
-
-REGISTER_FUNCTION(SparkLeast)
-{
-    factory.registerFunction<SparkFunctionLeast>();
-}
-}
diff --git 
a/cpp-ch/local-engine/Parser/scalar_function_parser/CommonScalarFunctionParser.cpp
 
b/cpp-ch/local-engine/Parser/scalar_function_parser/CommonScalarFunctionParser.cpp
index ec8b4e0d12..e4a56194c1 100644
--- 
a/cpp-ch/local-engine/Parser/scalar_function_parser/CommonScalarFunctionParser.cpp
+++ 
b/cpp-ch/local-engine/Parser/scalar_function_parser/CommonScalarFunctionParser.cpp
@@ -98,8 +98,8 @@ REGISTER_COMMON_SCALAR_FUNCTION_PARSER(Unhex, unhex, unhex);
 REGISTER_COMMON_SCALAR_FUNCTION_PARSER(Hypot, hypot, hypot);
 REGISTER_COMMON_SCALAR_FUNCTION_PARSER(Sign, sign, sign);
 REGISTER_COMMON_SCALAR_FUNCTION_PARSER(Radians, radians, radians);
-REGISTER_COMMON_SCALAR_FUNCTION_PARSER(Greatest, greatest, sparkGreatest);
-REGISTER_COMMON_SCALAR_FUNCTION_PARSER(Least, least, sparkLeast);
+REGISTER_COMMON_SCALAR_FUNCTION_PARSER(Greatest, greatest, greatest);
+REGISTER_COMMON_SCALAR_FUNCTION_PARSER(Least, least, least);
 REGISTER_COMMON_SCALAR_FUNCTION_PARSER(Rand, rand, randCanonical);
 REGISTER_COMMON_SCALAR_FUNCTION_PARSER(Bin, bin, sparkBin);
 REGISTER_COMMON_SCALAR_FUNCTION_PARSER(Rint, rint, sparkRint);
diff --git 
a/gluten-ut/spark32/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala
 
b/gluten-ut/spark32/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala
index 2eb5bd11ff..36d5b5177c 100644
--- 
a/gluten-ut/spark32/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala
+++ 
b/gluten-ut/spark32/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala
@@ -554,8 +554,6 @@ class ClickHouseTestSettings extends BackendTestSettings {
     .exclude("SPARK-17617: % (Remainder) double % double on super big double")
     .exclude("Abs")
     .exclude("pmod")
-    .exclude("function least")
-    .exclude("function greatest")
     .exclude("SPARK-28322: IntegralDivide supports decimal type")
     .exclude("SPARK-33008: division by zero on divide-like operations returns 
incorrect result")
     .exclude("SPARK-34920: error class")
diff --git 
a/gluten-ut/spark33/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala
 
b/gluten-ut/spark33/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala
index a7bf5d4da9..b9bf4e1ac4 100644
--- 
a/gluten-ut/spark33/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala
+++ 
b/gluten-ut/spark33/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala
@@ -570,8 +570,6 @@ class ClickHouseTestSettings extends BackendTestSettings {
     .exclude("SPARK-17617: % (Remainder) double % double on super big double")
     .exclude("Abs")
     .exclude("pmod")
-    .exclude("function least")
-    .exclude("function greatest")
     .exclude("SPARK-28322: IntegralDivide supports decimal type")
     .exclude("SPARK-33008: division by zero on divide-like operations returns 
incorrect result")
     .exclude("SPARK-34920: error class")
diff --git 
a/gluten-ut/spark34/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala
 
b/gluten-ut/spark34/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala
index b7e3905740..a407c5d682 100644
--- 
a/gluten-ut/spark34/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala
+++ 
b/gluten-ut/spark34/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala
@@ -513,8 +513,6 @@ class ClickHouseTestSettings extends BackendTestSettings {
     .exclude("SPARK-17617: % (Remainder) double % double on super big double")
     .exclude("Abs")
     .exclude("pmod")
-    .exclude("function least")
-    .exclude("function greatest")
     .exclude("SPARK-28322: IntegralDivide supports decimal type")
     .exclude("SPARK-33008: division by zero on divide-like operations returns 
incorrect result")
     .exclude("SPARK-34920: error class")
diff --git 
a/gluten-ut/spark35/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala
 
b/gluten-ut/spark35/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala
index 8ce145735d..9c22af0434 100644
--- 
a/gluten-ut/spark35/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala
+++ 
b/gluten-ut/spark35/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala
@@ -513,8 +513,6 @@ class ClickHouseTestSettings extends BackendTestSettings {
     .exclude("SPARK-17617: % (Remainder) double % double on super big double")
     .exclude("Abs")
     .exclude("pmod")
-    .exclude("function least")
-    .exclude("function greatest")
     .exclude("SPARK-28322: IntegralDivide supports decimal type")
     .exclude("SPARK-33008: division by zero on divide-like operations returns 
incorrect result")
     .exclude("SPARK-34920: error class")


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

Reply via email to