diff --git a/core/trino-main/src/main/java/io/trino/operator/scalar/MathFunctions.java b/core/trino-main/src/main/java/io/trino/operator/scalar/MathFunctions.java index dd013b886e81..05b8470f16a2 100644 --- a/core/trino-main/src/main/java/io/trino/operator/scalar/MathFunctions.java +++ b/core/trino-main/src/main/java/io/trino/operator/scalar/MathFunctions.java @@ -1155,6 +1155,14 @@ public static double sin(@SqlType(StandardTypes.DOUBLE) double num) return Math.sin(num); } + @Description("Hyperbolic sine") + @ScalarFunction + @SqlType(StandardTypes.DOUBLE) + public static double sinh(@SqlType(StandardTypes.DOUBLE) double num) + { + return Math.sinh(num); + } + @Description("Square root") @ScalarFunction @SqlType(StandardTypes.DOUBLE) diff --git a/core/trino-main/src/test/java/io/trino/operator/scalar/TestMathFunctions.java b/core/trino-main/src/test/java/io/trino/operator/scalar/TestMathFunctions.java index a3b841fcafe2..b1164e0c5cd5 100644 --- a/core/trino-main/src/test/java/io/trino/operator/scalar/TestMathFunctions.java +++ b/core/trino-main/src/test/java/io/trino/operator/scalar/TestMathFunctions.java @@ -2500,6 +2500,21 @@ public void testSin() .isNull(DOUBLE); } + @Test + public void testSinh() + { + for (double doubleValue : DOUBLE_VALUES) { + assertThat(assertions.function("sinh", Double.toString(doubleValue))) + .isEqualTo(Math.sinh(doubleValue)); + + assertThat(assertions.function("sinh", "REAL '%s'".formatted((float) doubleValue))) + .isEqualTo(Math.sinh((float) doubleValue)); + } + + assertThat(assertions.function("sinh", "NULL")) + .isNull(DOUBLE); + } + @Test public void testSqrt() { diff --git a/docs/src/main/sphinx/functions/list-by-topic.rst b/docs/src/main/sphinx/functions/list-by-topic.rst index 9cdaddddbaf4..0878e371ec3c 100644 --- a/docs/src/main/sphinx/functions/list-by-topic.rst +++ b/docs/src/main/sphinx/functions/list-by-topic.rst @@ -412,6 +412,7 @@ For more details, see :doc:`math` * :func:`round` * :func:`sign` * :func:`sin` +* :func:`sinh` * :func:`sqrt` * :func:`tan` * :func:`tanh` diff --git a/docs/src/main/sphinx/functions/list.rst b/docs/src/main/sphinx/functions/list.rst index ddd091f81322..9217e852246e 100644 --- a/docs/src/main/sphinx/functions/list.rst +++ b/docs/src/main/sphinx/functions/list.rst @@ -386,6 +386,7 @@ S - :func:`sign` - :func:`simplify_geometry` - :func:`sin` +- :func:`sinh` - :func:`skewness` - :func:`slice` - :ref:`SOME ` diff --git a/docs/src/main/sphinx/functions/math.rst b/docs/src/main/sphinx/functions/math.rst index 34e1b086487f..c6b6d31318c0 100644 --- a/docs/src/main/sphinx/functions/math.rst +++ b/docs/src/main/sphinx/functions/math.rst @@ -186,6 +186,10 @@ See unit conversion functions :func:`degrees` and :func:`radians`. Returns the sine of ``x``. +.. function:: sinh(x) -> double + + Returns the hyperbolic sine of ``x``. + .. function:: tan(x) -> double Returns the tangent of ``x``. diff --git a/testing/trino-product-tests/src/main/resources/sql-tests/testcases/math_functions/checkMathFunctionsRegistered.result b/testing/trino-product-tests/src/main/resources/sql-tests/testcases/math_functions/checkMathFunctionsRegistered.result index f635924115bf..48d3a97c68f9 100644 --- a/testing/trino-product-tests/src/main/resources/sql-tests/testcases/math_functions/checkMathFunctionsRegistered.result +++ b/testing/trino-product-tests/src/main/resources/sql-tests/testcases/math_functions/checkMathFunctionsRegistered.result @@ -71,6 +71,7 @@ round | double | double, integer | scalar | true | Round to given number of decimal places | row_number | bigint | | window | true | | sin | double | double | scalar | true | Sine | + sinh | double | double | scalar | true | Hyperbolic sine | sqrt | double | double | scalar | true | Square root | stddev | double | bigint | aggregate | true | Returns the sample standard deviation of the argument | stddev | double | double | aggregate | true | Returns the sample standard deviation of the argument |