Skip to content
Open
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
1 change: 1 addition & 0 deletions modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@
***** xref:reference:sql/sql-functions/math-functions/sin.adoc[]
***** xref:reference:sql/sql-functions/math-functions/sinh.adoc[]
***** xref:reference:sql/sql-functions/math-functions/sqrt.adoc[]
***** xref:reference:sql/sql-functions/math-functions/tanh.adoc[]
***** xref:reference:sql/sql-functions/math-functions/to-char-from-number.adoc[]
**** xref:reference:sql/sql-functions/other-functions/index.adoc[Other]
***** xref:reference:sql/sql-functions/other-functions/coalesce.adoc[]
Expand Down
2 changes: 1 addition & 1 deletion modules/reference/pages/sql/sql-data-types/interval.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ SELECT INTERVAL '2-4 5 DAYS 04:05:06.070809' YEAR TO MONTH as "Interval";
=== Extract data from interval
To extract interval numbers from a timestamp, use the `EXTRACT` function:
To extract interval numbers from a timestamp, use the `extract` function:
[source,sql]
----
Expand Down
4 changes: 2 additions & 2 deletions modules/reference/pages/sql/sql-data-types/text.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ The following output shows the created table:
+---------------+---------------+---------------+
----

== Text with SUBSTR function
== Text with substr function

The `SUBSTR` function extracts a specific number of characters from a text.
The `substr` function extracts a specific number of characters from a text.

=== Syntax

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
= GREATEST
:description: The `GREATEST` function returns the largest value from a set of values.
= greatest
:description: The `greatest` function returns the largest value from a set of values.
:page-topic-type: reference

The `GREATEST` function returns the greatest value from a set of values. The arguments must be of compatible types. For example, comparing a text value with a number returns an error.
The `greatest` function returns the greatest value from a set of values. The arguments must be of compatible types. For example, comparing a text value with a number returns an error.

== Syntax

Expand Down Expand Up @@ -98,7 +98,7 @@ greatest

=== Use table data

You can also use `GREATEST` to find the greatest value across columns. For example, create a table named `Student` that stores student names and scores.
You can also use `greatest` to find the greatest value across columns. For example, create a table named `Student` that stores student names and scores.

[source,sql]
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Mathematical, trigonometric, and hyperbolic functions in Redpanda SQL are design
|xref:reference:sql/sql-functions/math-functions/ceil.adoc[`ceil()`] |This function rounds up to the nearest positive or negative integer value greater than or equal to the argument
|xref:reference:sql/sql-functions/math-functions/exp.adoc[`exp()`] |This function returns the exponential value of a number specified in the argument
|xref:reference:sql/sql-functions/math-functions/floor.adoc[`floor()`] |This function returns a number rounded down that is less than or equal to the specified argument
|xref:reference:sql/sql-functions/math-functions/greatest.adoc[`GREATEST`] |This function extracts the greatest or largest value from a set of values.
|xref:reference:sql/sql-functions/math-functions/least.adoc[`LEAST`] |This function returns the least or smallest value in a list of values
|xref:reference:sql/sql-functions/math-functions/greatest.adoc[`greatest()`] |This function extracts the greatest or largest value from a set of values.
|xref:reference:sql/sql-functions/math-functions/least.adoc[`least()`] |This function returns the least or smallest value in a list of values
|xref:reference:sql/sql-functions/math-functions/ln.adoc[`ln()`] |This function returns the natural logarithm (base e) of its argument
|xref:reference:sql/sql-functions/math-functions/log.adoc[`log()`] |This function returns the base-10 logarithm or logarithm of the specified base of a given number
|xref:reference:sql/sql-functions/math-functions/power.adoc[`power()`] |This function returns the value of a number raised to the power of another number specified in the arguments
Expand Down Expand Up @@ -45,7 +45,7 @@ These trigonometric functions take arguments and return values of type `double p
|`cosd` |Calculates the cosine of a given argument, where the argument is in degrees. |`cosd(argument)` |`select cosd(60);` Returns: `0.5000000000000001`
|`cot` |Calculates the cotangent of a given argument, where the argument is in radians. |`cot(argument)` |`select cot(0.5);` Returns: `1.8304877`
|`cotd` |Calculates the cotangent of a given argument, where the argument is in degrees. |`cotd(argument)` |`select cotd(45);` Returns: `1.0000000000000002`
|xref:reference:sql/sql-functions/math-functions/sin.adoc[sin] |Calculates the sine of a given argument, where the argument is in radians. |`sin(argument)` |`select sin(1);` Returns: `0.8414709848078965`
|xref:reference:sql/sql-functions/math-functions/sin.adoc[`sin`] |Calculates the sine of a given argument, where the argument is in radians. |`sin(argument)` |`select sin(1);` Returns: `0.8414709848078965`
|`sind` |Calculates the sine of a given argument, where the argument is in degrees. |`sind(argument)` |`select sind(30);` Returns: `0.49999999999999994`
|`tan` |Calculates the tangent of a given argument, where the argument is in radians. |`tan(argument)` |`select tan(1);` Returns: `1.5574077246549023`
|`tand` |Calculates the tangent of a given argument, where the argument is in degrees. |`tand(argument)` |`select tand(45);` Returns: `0.9999999999999999`
Expand All @@ -56,6 +56,7 @@ These trigonometric functions take arguments and return values of type `double p
[width="100%",cols="6%,32%,26%,36%",options="header",]
|===
|*Function* |*Description* |*Syntax* |*Example*
|xref:reference:sql/sql-functions/math-functions/cosh.adoc[cosh] |Calculates the hyperbolic cosine of a given argument. |`cosh(argument)` |`select cosh(1);` Returns: `1.5430806348152437`
|xref:reference:sql/sql-functions/math-functions/sinh.adoc[sinh] |Calculates the hyperbolic sine of a given argument. |`sinh(argument)` |`select sinh(1);` Returns: `1.1752011936438014`
|xref:reference:sql/sql-functions/math-functions/cosh.adoc[`cosh`] |Calculates the hyperbolic cosine of a given argument. |`cosh(argument)` |`select cosh(1);` Returns: `1.5430806348152437`
|xref:reference:sql/sql-functions/math-functions/sinh.adoc[`sinh`] |Calculates the hyperbolic sine of a given argument. |`sinh(argument)` |`select sinh(1);` Returns: `1.1752011936438014`
|xref:reference:sql/sql-functions/math-functions/tanh.adoc[`tanh`] |Calculates the hyperbolic tangent of a given argument. |`tanh(argument)` |`select tanh(1);` Returns: `0.7615941559557649`
|===
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
= LEAST
:description: The `LEAST` function returns the smallest value in a list of values.
= least
:description: The `least` function returns the smallest value in a list of values.
:page-topic-type: reference

The `LEAST` function returns the least or smallest value in a list of values. It needs at least one argument to work with. If different types are mixed, like a text and a number, it returns an error.
The `least` function returns the least or smallest value in a list of values. It needs at least one argument to work with. If different types are mixed, like a text and a number, it returns an error.

For example, comparing the greatest value among 4, "`two`", and 9 would result in an error.

== Syntax

The syntax for the `LEAST` function is:
The syntax for the `least` function is:

[source,sql]
----
Expand All @@ -29,7 +29,7 @@ Where:

== Examples

These examples show how to use the `LEAST` function:
These examples show how to use the `least` function:

=== Basic usage

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
= tanh
:description: The `tanh()` function returns the hyperbolic tangent of a specified numeric argument.
:page-topic-type: reference

The `tanh()` function returns the hyperbolic tangent of a specified numeric argument.

== Syntax

[source,sql]
----
TANH(x)
----

== Arguments

* `x`: A number of type `real` or `double precision`, including zero.

== Return type

Same as the input type (`real` or `double precision`).

== Examples

=== Positive value

[source,sql]
----
SELECT TANH(1);
----

[source,sql]
----
tanh
--------------------
0.7615941559557649
(1 row)
----

=== Negative value

`TANH(-x)` returns the negative of `TANH(x)`:

[source,sql]
----
SELECT TANH(-1);
----

[source,sql]
----
tanh
---------------------
-0.7615941559557649
(1 row)
----

=== Zero

[source,sql]
----
SELECT TANH(0);
----

[source,sql]
----
tanh
------
0
(1 row)
----
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
= COALESCE
:description: The `COALESCE` function returns the first non-NULL argument from a list of arguments.
= coalesce
:description: The `coalesce` function returns the first non-NULL argument from a list of arguments.
:page-topic-type: reference

The `COALESCE` function returns the first non-NULL argument from a list of arguments. After finding the first non-NULL argument, the function stops evaluating the remaining arguments.
The `coalesce` function returns the first non-NULL argument from a list of arguments. After finding the first non-NULL argument, the function stops evaluating the remaining arguments.

[NOTE]
====
If all arguments are NULL, `COALESCE` returns NULL.
If all arguments are NULL, `coalesce` returns NULL.
====

== Syntax
Expand All @@ -20,17 +20,17 @@ COALESCE (argument_1, argument_2, …);

Key points from the syntax:

* `COALESCE` requires a minimum of two inputs.
* `coalesce` requires a minimum of two inputs.
* It can take an unlimited number of arguments.
* Evaluation occurs sequentially from left to right, stopping at the first non-null value.

== Examples

Here are some examples to illustrate the application of `COALESCE`:
Here are some examples to illustrate the application of `coalesce`:

=== Return the first non-null value

In this example, a set of values is provided. The `COALESCE` function returns the first non-null value from this set.
In this example, a set of values is provided. The `coalesce` function returns the first non-null value from this set.

[source,sql]
----
Expand Down Expand Up @@ -91,7 +91,7 @@ In this query, NULL appears in the first, second, fourth, and last positions:
Select COALESCE(NULL, NULL ,3, NULL, 7,9,4,5, NULL);
----

The `COALESCE` function ignores the first two NULLs and returns the first non-null value, `3`. It does not process the subsequent NULL values.
The `coalesce` function ignores the first two NULLs and returns the first non-null value, `3`. It does not process the subsequent NULL values.

[source,sql]
----
Expand All @@ -109,15 +109,15 @@ Assume that the given values are entirely composed of nulls.
Select COALESCE(NULL, NULL ,NULL, NULL);
----

In this case, the `COALESCE` function returns an empty value (NULL).
In this case, the `coalesce` function returns an empty value (NULL).

[source,sql]
----
coalesce
----------
----

=== `COALESCE` with table data
=== `coalesce` with table data

Consider the `employee_absent` table, which comprises a mix of NULL and non-null values:

Expand Down Expand Up @@ -156,7 +156,7 @@ SELECT * FROM employee_absent;
Emily | HR |
----

The following query uses the `COALESCE` function on the `absent` column. It retrieves names and absences (with `out of office` for NULL values) for each employee.
The following query uses the `coalesce` function on the `absent` column. It retrieves names and absences (with `out of office` for NULL values) for each employee.

[source,sql]
----
Expand All @@ -174,7 +174,7 @@ SELECT emp_name, COALESCE(absent, 'out of office') AS DisplayAbsent FROM employe
Emily | out of office
----

=== Error output in `COALESCE`
=== Error output in `coalesce`

When specifying arguments with different datatypes, they should be convertible.

Expand All @@ -183,7 +183,7 @@ When specifying arguments with different datatypes, they should be convertible.
Select Coalesce ('x',NULL,1);
----

If the datatypes cannot be converted, the `COALESCE` function generates an error.
If the datatypes cannot be converted, the `coalesce` function generates an error.

[source,sql]
----
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
= Other Functions
:description: Reference for other Redpanda SQL functions, including `COALESCE`, `NULLIF`, and PostgreSQL system information functions.
:description: Reference for other Redpanda SQL functions, including `coalesce`, `nullif`, and PostgreSQL system information functions.
:page-topic-type: reference

Besides xref:reference:sql/sql-functions/math-functions/index.adoc[math], xref:reference:sql/sql-functions/aggregate-functions/index.adoc[aggregate], xref:reference:sql/sql-functions/window-functions/index.adoc[window], xref:reference:sql/sql-functions/string-functions/index.adoc[string], xref:reference:sql/sql-functions/timestamp-functions/index.adoc[timestamp], and xref:reference:sql/sql-functions/json-functions/index.adoc[`json`] functions, Redpanda SQL also supports these functions:

[cols="46%,54%",options="header",]
|===
|Function |Description
|xref:reference:sql/sql-functions/other-functions/coalesce.adoc[`COALESCE`] |Returns the first argument that is not NULL, while the remaining arguments from the first non-null argument are not evaluated.
|xref:reference:sql/sql-functions/other-functions/current-database.adoc[current_database()] |Returns the current database's name.
|xref:reference:sql/sql-functions/other-functions/current-schema.adoc[current_schema()] |Returns the schema's name (first in the search path).
|xref:reference:sql/sql-functions/other-functions/has-schema-privilege.adoc[has_schema_privilege()] |Checks whether the current user has specific privileges on a schema.
|xref:reference:sql/sql-functions/other-functions/nullif.adoc[`NULLIF`] |Replaces a given value with NULL if it matches a specific criterion.
|xref:reference:sql/sql-functions/other-functions/pg-get-expr.adoc[pg_get_expr()] |Retrieves the internal form of an individual expression (such as the default value for a column).
|xref:reference:sql/sql-functions/other-functions/pg-total-relation-size.adoc[pg_total_relation_size()] |Retrieves the size of a table.
|xref:reference:sql/sql-functions/other-functions/pg-typeof.adoc[pg_typeof()] |Retrieves the data type of any given value.
|xref:reference:sql/sql-functions/other-functions/pg-encoding-to-char.adoc[pg_encoding_to_char()] |Converts an encoding internal identifier to a human-readable name.
|xref:reference:sql/sql-functions/other-functions/pg-get-indexdef.adoc[pg_get_indexdef()] |Reconstructs the PostgreSQL command used to retrieve the definition of a specified index.
|xref:reference:sql/sql-functions/other-functions/pg-get-userbyid.adoc[pg_get_userbyid()] |Retrieves the name of a user (role) given its unique identifier (OID).
|xref:reference:sql/sql-functions/other-functions/pg-relation-is-publishable.adoc[pg_relation_is_publishable()] |Determines whether a specified relation (table) can be published in a publication.
|xref:reference:sql/sql-functions/other-functions/pg-size-pretty.adoc[pg_size_pretty()] |Converts sizes in bytes into a human-readable format.
|xref:reference:sql/sql-functions/other-functions/pg-table-size.adoc[pg_table_size()] |Retrieves the size of a specific table, including its associated storage components but excluding indexes.
|xref:reference:sql/sql-functions/other-functions/pg-table-is-visible.adoc[pg_table_is_visible()] |Checks whether a specified table (or other database object) is visible in the current schema search path.
|xref:reference:sql/sql-functions/other-functions/pg-get-constraintdef.adoc[pg_get_constraintdef()] |Retrieves the definition of a specific constraint in a human-readable format.
|xref:reference:sql/sql-functions/other-functions/pg-get-statisticsobjdef-columns.adoc[pg_get_statisticsobjdef_columns()] |Retrieves the definitions of columns associated with a specified statistics object.
|xref:reference:sql/sql-functions/other-functions/obj-description.adoc[obj_description()] |Returns the comment associated with a specific database object.
|xref:reference:sql/sql-functions/other-functions/col-description.adoc[col_description()] |Retrieves the comment associated with a specified table column based on its name.
|xref:reference:sql/sql-functions/other-functions/shobj-description.adoc[shobj_description()] |Retrieves the comment associated with a shared database object.
|xref:reference:sql/sql-functions/other-functions/pg-backend-pid.adoc[pg_backend_pid()] |Returns the process ID (PID) of the node handling the current session.
|xref:reference:sql/sql-functions/other-functions/coalesce.adoc[`coalesce()`] |Returns the first argument that is not NULL, while the remaining arguments from the first non-null argument are not evaluated.
|xref:reference:sql/sql-functions/other-functions/current-database.adoc[`current_database()`] |Returns the current database's name.
|xref:reference:sql/sql-functions/other-functions/current-schema.adoc[`current_schema()`] |Returns the schema's name (first in the search path).
|xref:reference:sql/sql-functions/other-functions/has-schema-privilege.adoc[`has_schema_privilege()`] |Checks whether the current user has specific privileges on a schema.
|xref:reference:sql/sql-functions/other-functions/nullif.adoc[`nullif()`] |Replaces a given value with NULL if it matches a specific criterion.
|xref:reference:sql/sql-functions/other-functions/pg-get-expr.adoc[`pg_get_expr()`] |Retrieves the internal form of an individual expression (such as the default value for a column).
|xref:reference:sql/sql-functions/other-functions/pg-total-relation-size.adoc[`pg_total_relation_size()`] |Retrieves the size of a table.
|xref:reference:sql/sql-functions/other-functions/pg-typeof.adoc[`pg_typeof()`] |Retrieves the data type of any given value.
|xref:reference:sql/sql-functions/other-functions/pg-encoding-to-char.adoc[`pg_encoding_to_char()`] |Converts an encoding internal identifier to a human-readable name.
|xref:reference:sql/sql-functions/other-functions/pg-get-indexdef.adoc[`pg_get_indexdef()`] |Reconstructs the PostgreSQL command used to retrieve the definition of a specified index.
|xref:reference:sql/sql-functions/other-functions/pg-get-userbyid.adoc[`pg_get_userbyid()`] |Retrieves the name of a user (role) given its unique identifier (OID).
|xref:reference:sql/sql-functions/other-functions/pg-relation-is-publishable.adoc[`pg_relation_is_publishable()`] |Determines whether a specified relation (table) can be published in a publication.
|xref:reference:sql/sql-functions/other-functions/pg-size-pretty.adoc[`pg_size_pretty()`] |Converts sizes in bytes into a human-readable format.
|xref:reference:sql/sql-functions/other-functions/pg-table-size.adoc[`pg_table_size()`] |Retrieves the size of a specific table, including its associated storage components but excluding indexes.
|xref:reference:sql/sql-functions/other-functions/pg-table-is-visible.adoc[`pg_table_is_visible()`] |Checks whether a specified table (or other database object) is visible in the current schema search path.
|xref:reference:sql/sql-functions/other-functions/pg-get-constraintdef.adoc[`pg_get_constraintdef()`] |Retrieves the definition of a specific constraint in a human-readable format.
|xref:reference:sql/sql-functions/other-functions/pg-get-statisticsobjdef-columns.adoc[`pg_get_statisticsobjdef_columns()`] |Retrieves the definitions of columns associated with a specified statistics object.
|xref:reference:sql/sql-functions/other-functions/obj-description.adoc[`obj_description()`] |Returns the comment associated with a specific database object.
|xref:reference:sql/sql-functions/other-functions/col-description.adoc[`col_description()`] |Retrieves the comment associated with a specified table column based on its name.
|xref:reference:sql/sql-functions/other-functions/shobj-description.adoc[`shobj_description()`] |Retrieves the comment associated with a shared database object.
|xref:reference:sql/sql-functions/other-functions/pg-backend-pid.adoc[`pg_backend_pid()`] |Returns the process ID (PID) of the node handling the current session.
|===
Loading
Loading