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

morrysnow pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-3.1 by this push:
     new 7e0800ac02f branch-3.1: [Feature](function) support function 
cot/sec/cosec #52872 (#53273)
7e0800ac02f is described below

commit 7e0800ac02f7540a3facf553bf0686b39a2b5205
Author: Pxl <[email protected]>
AuthorDate: Wed Jul 16 10:59:29 2025 +0800

    branch-3.1: [Feature](function) support function cot/sec/cosec #52872 
(#53273)
    
    pick from #52872
---
 be/src/vec/functions/math.cpp                      |  27 ++++++++
 be/test/vec/function/function_math_test.cpp        |  31 ++++++++++
 .../doris/catalog/BuiltinScalarFunctions.java      |   6 ++
 .../functions/executable/NumericArithmetic.java    |  33 ++++++++++
 .../trees/expressions/functions/scalar/Cosec.java  |  68 +++++++++++++++++++++
 .../trees/expressions/functions/scalar/Cot.java    |  68 +++++++++++++++++++++
 .../trees/expressions/functions/scalar/Sec.java    |  68 +++++++++++++++++++++
 .../expressions/visitor/ScalarFunctionVisitor.java |  15 +++++
 .../sql_functions/math_functions/test_triangle.out | Bin 0 -> 1103 bytes
 .../fold_constant_numeric_arithmatic.groovy        |  33 ++++++++++
 .../math_functions/test_triangle.groovy            |  50 +++++++++++++++
 11 files changed, 399 insertions(+)

diff --git a/be/src/vec/functions/math.cpp b/be/src/vec/functions/math.cpp
index 2d9faaf19bc..711a92ebb9d 100644
--- a/be/src/vec/functions/math.cpp
+++ b/be/src/vec/functions/math.cpp
@@ -270,6 +270,30 @@ struct TanhName {
 };
 using FunctionTanh = FunctionMathUnary<UnaryFunctionPlain<TanhName, 
std::tanh>>;
 
+struct CotName {
+    static constexpr auto name = "cot";
+};
+double cot(double x) {
+    return 1.0 / std::tan(x);
+}
+using FunctionCot = FunctionMathUnary<UnaryFunctionPlain<CotName, cot>>;
+
+struct SecName {
+    static constexpr auto name = "sec";
+};
+double sec(double x) {
+    return 1.0 / std::cos(x);
+}
+using FunctionSec = FunctionMathUnary<UnaryFunctionPlain<SecName, sec>>;
+
+struct CosecName {
+    static constexpr auto name = "cosec";
+};
+double cosec(double x) {
+    return 1.0 / std::sin(x);
+}
+using FunctionCosec = FunctionMathUnary<UnaryFunctionPlain<CosecName, cosec>>;
+
 template <typename A>
 struct RadiansImpl {
     using ResultType = A;
@@ -450,6 +474,9 @@ void register_function_math(SimpleFunctionFactory& factory) 
{
     factory.register_function<FunctionCbrt>();
     factory.register_function<FunctionTan>();
     factory.register_function<FunctionTanh>();
+    factory.register_function<FunctionCot>();
+    factory.register_function<FunctionSec>();
+    factory.register_function<FunctionCosec>();
     factory.register_function<FunctionPow>();
     factory.register_alias("pow", "power");
     factory.register_alias("pow", "dpow");
diff --git a/be/test/vec/function/function_math_test.cpp 
b/be/test/vec/function/function_math_test.cpp
index 63a1b964a0c..e4fec957f44 100644
--- a/be/test/vec/function/function_math_test.cpp
+++ b/be/test/vec/function/function_math_test.cpp
@@ -119,6 +119,37 @@ TEST(MathFunctionTest, cbrt_test) {
     static_cast<void>(check_function<DataTypeFloat64, true>(func_name, 
input_types, data_set));
 }
 
+TEST(MathFunctionTest, cot_test) {
+    std::string func_name = "cot";
+
+    InputTypeSet input_types = {TypeIndex::Float64};
+
+    DataSet data_set = {{{1.0}, 0.6420926159343306}, {{M_PI / 4}, 
1.0000000000000002}};
+
+    static_cast<void>(check_function<DataTypeFloat64, true>(func_name, 
input_types, data_set));
+}
+
+TEST(MathFunctionTest, sec_test) {
+    std::string func_name = "sec";
+
+    InputTypeSet input_types = {TypeIndex::Float64};
+
+    DataSet data_set = {{{1.0}, 1.8508157176809255}, {{1000.0}, 
1.7781600385912715}};
+
+    static_cast<void>(check_function<DataTypeFloat64, true>(func_name, 
input_types, data_set));
+}
+
+TEST(MathFunctionTest, cosec_test) {
+    std::string func_name = "cosec";
+
+    InputTypeSet input_types = {TypeIndex::Float64};
+
+    DataSet data_set = {
+            {{1.0}, 1.1883951057781212}, {{2.0}, 1.0997501702946164}, 
{{1000.0}, 1.20936599707935}};
+
+    static_cast<void>(check_function<DataTypeFloat64, true>(func_name, 
input_types, data_set));
+}
+
 TEST(MathFunctionTest, tan_test) {
     std::string func_name = "tan"; //tan(x)
 
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java
index f36d27376b3..ea49acefd67 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java
@@ -123,8 +123,10 @@ import 
org.apache.doris.nereids.trees.expressions.functions.scalar.Conv;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.ConvertTo;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.ConvertTz;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.Cos;
+import org.apache.doris.nereids.trees.expressions.functions.scalar.Cosec;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.Cosh;
 import 
org.apache.doris.nereids.trees.expressions.functions.scalar.CosineDistance;
+import org.apache.doris.nereids.trees.expressions.functions.scalar.Cot;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.CountEqual;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.Crc32;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.CreateMap;
@@ -365,6 +367,7 @@ import 
org.apache.doris.nereids.trees.expressions.functions.scalar.RoundBankers;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.Rpad;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.Rtrim;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.RtrimIn;
+import org.apache.doris.nereids.trees.expressions.functions.scalar.Sec;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.SecToTime;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.Second;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.SecondCeil;
@@ -600,7 +603,9 @@ public class BuiltinScalarFunctions implements 
FunctionHelper {
             scalar(ConvertTo.class, "convert_to"),
             scalar(ConvertTz.class, "convert_tz"),
             scalar(Cos.class, "cos"),
+            scalar(Cosec.class, "cosec"),
             scalar(Cosh.class, "cosh"),
+            scalar(Cot.class, "cot"),
             scalar(CosineDistance.class, "cosine_distance"),
             scalar(CountEqual.class, "countequal"),
             scalar(CreateMap.class, "map"),
@@ -855,6 +860,7 @@ public class BuiltinScalarFunctions implements 
FunctionHelper {
             scalar(Rpad.class, "rpad"),
             scalar(Rtrim.class, "rtrim"),
             scalar(RtrimIn.class, "rtrim_in"),
+            scalar(Sec.class, "sec"),
             scalar(Second.class, "second"),
             scalar(SecondCeil.class, "second_ceil"),
             scalar(SecondFloor.class, "second_floor"),
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/NumericArithmetic.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/NumericArithmetic.java
index 1368d8adcf7..abf6363c035 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/NumericArithmetic.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/NumericArithmetic.java
@@ -915,6 +915,39 @@ public class NumericArithmetic {
         return checkOutputBoundary(new 
DoubleLiteral(Math.tan(first.getValue())));
     }
 
+    /**
+     * cot
+     */
+    @ExecFunction(name = "cot")
+    public static Expression cot(DoubleLiteral first) {
+        if (inputOutOfBound(first, Double.NEGATIVE_INFINITY, 
Double.POSITIVE_INFINITY, false, false)) {
+            return new NullLiteral(DoubleType.INSTANCE);
+        }
+        return checkOutputBoundary(new DoubleLiteral(1.0 / 
Math.tan(first.getValue())));
+    }
+
+    /**
+     * cot
+     */
+    @ExecFunction(name = "sec")
+    public static Expression sec(DoubleLiteral first) {
+        if (inputOutOfBound(first, Double.NEGATIVE_INFINITY, 
Double.POSITIVE_INFINITY, false, false)) {
+            return new NullLiteral(DoubleType.INSTANCE);
+        }
+        return checkOutputBoundary(new DoubleLiteral(1.0 / 
Math.cos(first.getValue())));
+    }
+
+    /**
+     * cosec
+     */
+    @ExecFunction(name = "cosec")
+    public static Expression cosec(DoubleLiteral first) {
+        if (inputOutOfBound(first, Double.NEGATIVE_INFINITY, 
Double.POSITIVE_INFINITY, false, false)) {
+            return new NullLiteral(DoubleType.INSTANCE);
+        }
+        return checkOutputBoundary(new DoubleLiteral(1.0 / 
Math.sin(first.getValue())));
+    }
+
     /**
      * asin
      */
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Cosec.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Cosec.java
new file mode 100644
index 00000000000..26919889a3a
--- /dev/null
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Cosec.java
@@ -0,0 +1,68 @@
+// 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.
+
+package org.apache.doris.nereids.trees.expressions.functions.scalar;
+
+import org.apache.doris.catalog.FunctionSignature;
+import org.apache.doris.nereids.trees.expressions.Expression;
+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.trees.expressions.visitor.ExpressionVisitor;
+import org.apache.doris.nereids.types.DoubleType;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+
+import java.util.List;
+
+/**S
+ * ScalarFunction 'cosec'. This class is generated by GenerateFunction.
+ */
+public class Cosec extends ScalarFunction
+        implements UnaryExpression, ExplicitlyCastableSignature, 
PropagateNullable {
+
+    public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
+            
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE)
+    );
+
+    /**
+     * constructor with 1 argument.
+     */
+    public Cosec(Expression arg) {
+        super("cosec", arg);
+    }
+
+    /**
+     * withChildren.
+     */
+    @Override
+    public Cosec withChildren(List<Expression> children) {
+        Preconditions.checkArgument(children.size() == 1);
+        return new Cosec(children.get(0));
+    }
+
+    @Override
+    public List<FunctionSignature> getSignatures() {
+        return SIGNATURES;
+    }
+
+    @Override
+    public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
+        return visitor.visitCosec(this, context);
+    }
+}
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Cot.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Cot.java
new file mode 100644
index 00000000000..842b035b6df
--- /dev/null
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Cot.java
@@ -0,0 +1,68 @@
+// 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.
+
+package org.apache.doris.nereids.trees.expressions.functions.scalar;
+
+import org.apache.doris.catalog.FunctionSignature;
+import org.apache.doris.nereids.trees.expressions.Expression;
+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.trees.expressions.visitor.ExpressionVisitor;
+import org.apache.doris.nereids.types.DoubleType;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+
+import java.util.List;
+
+/**
+ * ScalarFunction 'cot'. This class is generated by GenerateFunction.
+ */
+public class Cot extends ScalarFunction
+        implements UnaryExpression, ExplicitlyCastableSignature, 
PropagateNullable {
+
+    public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
+            
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE)
+    );
+
+    /**
+     * constructor with 1 argument.
+     */
+    public Cot(Expression arg) {
+        super("cot", arg);
+    }
+
+    /**
+     * withChildren.
+     */
+    @Override
+    public Cot withChildren(List<Expression> children) {
+        Preconditions.checkArgument(children.size() == 1);
+        return new Cot(children.get(0));
+    }
+
+    @Override
+    public List<FunctionSignature> getSignatures() {
+        return SIGNATURES;
+    }
+
+    @Override
+    public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
+        return visitor.visitCot(this, context);
+    }
+}
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sec.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sec.java
new file mode 100644
index 00000000000..dc6a188cd77
--- /dev/null
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sec.java
@@ -0,0 +1,68 @@
+// 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.
+
+package org.apache.doris.nereids.trees.expressions.functions.scalar;
+
+import org.apache.doris.catalog.FunctionSignature;
+import org.apache.doris.nereids.trees.expressions.Expression;
+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.trees.expressions.visitor.ExpressionVisitor;
+import org.apache.doris.nereids.types.DoubleType;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+
+import java.util.List;
+
+/**S
+ * ScalarFunction 'sec'. This class is generated by GenerateFunction.
+ */
+public class Sec extends ScalarFunction
+        implements UnaryExpression, ExplicitlyCastableSignature, 
PropagateNullable {
+
+    public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
+            
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE)
+    );
+
+    /**
+     * constructor with 1 argument.
+     */
+    public Sec(Expression arg) {
+        super("sec", arg);
+    }
+
+    /**
+     * withChildren.
+     */
+    @Override
+    public Sec withChildren(List<Expression> children) {
+        Preconditions.checkArgument(children.size() == 1);
+        return new Sec(children.get(0));
+    }
+
+    @Override
+    public List<FunctionSignature> getSignatures() {
+        return SIGNATURES;
+    }
+
+    @Override
+    public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
+        return visitor.visitSec(this, context);
+    }
+}
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java
index deecea03c08..c7b9ffe9b82 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java
@@ -131,8 +131,10 @@ import 
org.apache.doris.nereids.trees.expressions.functions.scalar.Conv;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.ConvertTo;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.ConvertTz;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.Cos;
+import org.apache.doris.nereids.trees.expressions.functions.scalar.Cosec;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.Cosh;
 import 
org.apache.doris.nereids.trees.expressions.functions.scalar.CosineDistance;
+import org.apache.doris.nereids.trees.expressions.functions.scalar.Cot;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.CountEqual;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.Crc32;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.CreateMap;
@@ -366,6 +368,7 @@ import 
org.apache.doris.nereids.trees.expressions.functions.scalar.Rpad;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.Rtrim;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.RtrimIn;
 import 
org.apache.doris.nereids.trees.expressions.functions.scalar.ScalarFunction;
+import org.apache.doris.nereids.trees.expressions.functions.scalar.Sec;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.Second;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.SecondCeil;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.SecondFloor;
@@ -2074,6 +2077,18 @@ public interface ScalarFunctionVisitor<R, C> {
         return visitScalarFunction(tanh, context);
     }
 
+    default R visitCot(Cot cot, C context) {
+        return visitScalarFunction(cot, context);
+    }
+
+    default R visitSec(Sec sec, C context) {
+        return visitScalarFunction(sec, context);
+    }
+
+    default R visitCosec(Cosec cosec, C context) {
+        return visitScalarFunction(cosec, context);
+    }
+
     default R visitTimeDiff(TimeDiff timeDiff, C context) {
         return visitScalarFunction(timeDiff, context);
     }
diff --git 
a/regression-test/data/query_p0/sql_functions/math_functions/test_triangle.out 
b/regression-test/data/query_p0/sql_functions/math_functions/test_triangle.out
new file mode 100644
index 00000000000..7fa4c9b3be9
Binary files /dev/null and 
b/regression-test/data/query_p0/sql_functions/math_functions/test_triangle.out 
differ
diff --git 
a/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_numeric_arithmatic.groovy
 
b/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_numeric_arithmatic.groovy
index 7aa09d8a186..97a70ac3c0c 100644
--- 
a/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_numeric_arithmatic.groovy
+++ 
b/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_numeric_arithmatic.groovy
@@ -474,6 +474,39 @@ suite("fold_constant_numeric_arithmatic") {
     testFoldConst("SELECT TANH(-0.5), TANH(0.5), TANH(10), TANH(-10)")
     testFoldConst("SELECT TANH(-20), TANH(20), TANH(1E-7), TANH(-1E-7)")
 
+//Cot function cases
+    testFoldConst("SELECT COT(PI() / 4)")
+    testFoldConst("SELECT COT(PI())")
+    testFoldConst("SELECT COT(PI() / 2)")
+    // testFoldConst("SELECT COT(0)") need rethink inf behavior
+    testFoldConst("SELECT COT(1)")
+    testFoldConst("SELECT COT(-1)")
+    testFoldConst("SELECT COT(NULL)")
+    testFoldConst("SELECT COT(-0.5), COT(0.5), COT(10), COT(-10)")
+    testFoldConst("SELECT COT(-20), COT(20), COT(1E-7), COT(-1E-7)")
+
+//Sec function cases
+    testFoldConst("SELECT SEC(PI() / 4)")
+    testFoldConst("SELECT SEC(PI())")
+    // testFoldConst("SELECT SEC(PI() / 2)") need rethink inf behavior
+    testFoldConst("SELECT SEC(0)")
+    testFoldConst("SELECT SEC(1)")
+    testFoldConst("SELECT SEC(-1)")
+    testFoldConst("SELECT SEC(NULL)")
+    testFoldConst("SELECT SEC(-0.5), SEC(0.5), SEC(10), SEC(-10)")
+    testFoldConst("SELECT SEC(-20), SEC(20), SEC(1E-7), SEC(-1E-7)")
+
+//Cosec function cases
+    testFoldConst("SELECT COSEC(PI() / 4)")
+    // testFoldConst("SELECT COSEC(PI())") need rethink inf behavior
+    testFoldConst("SELECT COSEC(PI() / 2)")
+    // testFoldConst("SELECT COSEC(0)") need rethink inf behavior
+    testFoldConst("SELECT COSEC(1)")
+    testFoldConst("SELECT COSEC(-1)")
+    testFoldConst("SELECT COSEC(NULL)")
+    testFoldConst("SELECT COSEC(-0.5), COSEC(0.5), COSEC(10), COSEC(-10)")
+    testFoldConst("SELECT COSEC(-20), COSEC(20), COSEC(1E-7), COSEC(-1E-7)")
+
 //Truncate function cases
     testFoldConst("SELECT TRUNCATE(123.456, 2) AS truncate_case_1") 
//truncate(123.456, 2) = 123.45
     testFoldConst("SELECT TRUNCATE(-123.456, 1) AS truncate_case_2") 
//truncate(-123.456, 1) = -123.4
diff --git 
a/regression-test/suites/query_p0/sql_functions/math_functions/test_triangle.groovy
 
b/regression-test/suites/query_p0/sql_functions/math_functions/test_triangle.groovy
new file mode 100644
index 00000000000..53e2b478ebd
--- /dev/null
+++ 
b/regression-test/suites/query_p0/sql_functions/math_functions/test_triangle.groovy
@@ -0,0 +1,50 @@
+// 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_triangle") {
+    sql """ drop table if exists test_triangle; """
+    sql """ create table test_triangle(
+        k1 int,
+        v1 double
+    ) distributed by hash (k1) buckets 1
+    properties ("replication_num"="1");
+    """
+    sql """ insert into test_triangle values
+        (1,PI() / 4),
+        (2,PI() / 2),
+        (3,PI()),
+        (4,0),
+        (5,1),
+        (6,-1),
+        (7,NULL),
+        (8,0.5),
+        (9,-0.5),
+        (10,10),
+        (11,-10),
+        (12,1E-7),
+        (13,1E-7),
+        (14,1E7),
+        (15,-1E7),
+        (16,-PI()),
+        (17,-PI()/2)
+    """
+
+    qt_test "select k1,COT(v1) from test_triangle order by k1;"
+    qt_test "select k1,SEC(v1) from test_triangle order by k1;"
+    qt_test "select k1,COSEC(v1) from test_triangle order by k1;"
+}
+


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

Reply via email to