Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sinh function to return hyperbolic sine #16535

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
1 change: 1 addition & 0 deletions docs/src/main/sphinx/functions/list-by-topic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ For more details, see :doc:`math`
* :func:`round`
* :func:`sign`
* :func:`sin`
* :func:`sinh`
* :func:`sqrt`
* :func:`tan`
* :func:`tanh`
Expand Down
1 change: 1 addition & 0 deletions docs/src/main/sphinx/functions/list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ S
- :func:`sign`
- :func:`simplify_geometry`
- :func:`sin`
- :func:`sinh`
- :func:`skewness`
- :func:`slice`
- :ref:`SOME <quantified_comparison_predicates>`
Expand Down
4 changes: 4 additions & 0 deletions docs/src/main/sphinx/functions/math.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down