Skip to content

Commit

Permalink
[Docs] batch 03 - trig functions (#16795)
Browse files Browse the repository at this point in the history
* batch 03 - trig functions

* Apply suggestions from code review

Co-authored-by: Charles Smith <[email protected]>

* applying suggestions and corrections

---------

Co-authored-by: Charles Smith <[email protected]>
  • Loading branch information
edgar2020 and techdocsmith authored Jul 26, 2024
1 parent ed48cb8 commit 028ee23
Show file tree
Hide file tree
Showing 2 changed files with 183 additions and 30 deletions.
210 changes: 180 additions & 30 deletions docs/querying/sql-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,26 @@ Returns the following:

## ACOS

`ACOS(<NUMERIC>)`
Calculates the arc cosine (arccosine) of a numeric expression.

**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
* **Syntax:** `ACOS(expr)`
* **Function type:** Scalar, numeric

<details><summary>Example</summary>

The following example calculates the arc cosine of `0`.

```sql
SELECT ACOS(0) AS "arc_cosine"
```
Returns the following:

Calculates the arc cosine of a numeric expression.
| `arc_cosine` |
| -- |
| `1.5707963267948966` |
</details>

[Learn more](sql-scalar.md#numeric-functions)

## ANY_VALUE

Expand Down Expand Up @@ -280,27 +295,72 @@ Joins all elements of `arr` by the delimiter specified by `str`.

## ASIN

`ASIN(<NUMERIC>)`
Calculates the arc sine (arcsine) of a numeric expression.

**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
* **Syntax:** `ASIN(expr)`
* **Function type:** Scalar, numeric

<details><summary>Example</summary>

The following example calculates the arc sine of `1`.

Calculates the arc sine of a numeric expression.
```sql
SELECT ASIN(1) AS "arc_sine"
```
Returns the following:

| `arc_sine` |
| -- |
| `1.5707963267948966` |
</details>

[Learn more](sql-scalar.md#numeric-functions)

## ATAN

`ATAN(<NUMERIC>)`
Calculates the arc tangent (arctangent) of a numeric expression.

**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
* **Syntax:** `ATAN(expr)`
* **Function type:** Scalar, numeric

<details><summary>Example</summary>

Calculates the arc tangent of a numeric expression.
The following example calculates the arc tangent of `1`.

```sql
SELECT ATAN(1) AS "arc_tangent"
```
Returns the following:

| `arc_tangent` |
| -- |
| `0.7853981633974483` |
</details>

[Learn more](sql-scalar.md#numeric-functions)

## ATAN2

`ATAN2(<NUMERIC>, <NUMERIC>)`
Calculates the arc tangent (arctangent) of a specified x and y coordinate.

**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
* **Syntax:** `ATAN2(x, y)`
* **Function type:** Scalar, numeric

<details><summary>Example</summary>

The following example calculates the arc tangent of the coordinate `(1, -1)`

```sql
SELECT ATAN2(1,-1) AS "arc_tangent_2"
```
Returns the following:

Calculates the arc tangent of the two arguments.
| `arc_tangent_2` |
| -- |
| `2.356194490192345` |
</details>

[Learn more](sql-scalar.md#numeric-functions)

## AVG

Expand Down Expand Up @@ -514,20 +574,50 @@ Finds whether a string is in a given expression, case-sensitive.

## COS

`COS(<NUMERIC>)`
Calculates the trigonometric cosine of an angle expressed in radians.

**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
* **Syntax:** `COS(expr)`
* **Function type:** Scalar, numeric

Calculates the trigonometric cosine of an angle expressed in radians.
<details><summary>Example</summary>

## COT
The following example calculates the cosine of angle `PI/3` radians.

`COT(<NUMERIC>)`
```sql
SELECT COS(PI / 3) AS "cosine"
```
Returns the following:

**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
| `cosine` |
| -- |
| `0.5000000000000001` |
</details>

[Learn more](sql-scalar.md#numeric-functions)

## COT

Calculates the trigonometric cotangent of an angle expressed in radians.

* **Syntax:** `COT(expr)`
* **Function type:** Scalar, numeric

<details><summary>Example</summary>

The following example calculates the cotangent of angle `PI/3` radians.

```sql
SELECT COT(PI / 3) AS "cotangent"
```
Returns the following:

| `cotangent` |
| -- |
| `0.577350269189626` |
</details>

[Learn more](sql-scalar.md#numeric-functions)

## COUNT

`COUNT([DISTINCT] expr)`
Expand Down Expand Up @@ -589,11 +679,26 @@ Decodes a Base64-encoded string into a UTF-8 encoded string.

## DEGREES

`DEGREES(<NUMERIC>)`
Converts an angle from radians to degrees.

**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
* **Syntax:** `DEGREES(expr)`
* **Function type:** Scalar, numeric

Converts an angle from radians to degrees.
<details><summary>Example</summary>

The following example converts an angle of `PI` radians to degrees

```sql
SELECT DEGREES(PI) AS "degrees"
```
Returns the following:

| `degrees` |
| -- |
| `180` |
</details>

[Learn more](sql-scalar.md#numeric-functions)

## DENSE_RANK

Expand Down Expand Up @@ -1374,11 +1479,26 @@ Returns the following:

## RADIANS

`RADIANS(expr)`
Converts an angle from degrees to radians.

* **Syntax:** `RADIANS(expr)`
* **Function type:** Scalar, numeric

**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
<details><summary>Example</summary>

Converts an angle from degrees to radians.
The following example converts an angle of `180` degrees to radians

```sql
SELECT RADIANS(180) AS "radians"
```
Returns the following:

| `radians` |
| -- |
| `3.141592653589793` |
</details>

[Learn more](sql-scalar.md#numeric-functions)

## RANK

Expand Down Expand Up @@ -1507,11 +1627,26 @@ Returns `x` divided by `y`, guarded on division by 0.

## SIN

`SIN(expr)`
Calculates the trigonometric sine of an angle expressed in radians.

**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
* **Syntax:** `SIN(expr)`
* **Function type:** Scalar, numeric

Calculates the trigonometric sine of an angle expressed in radians.
<details><summary>Example</summary>

The following example calculates the sine of angle `PI/3` radians.

```sql
SELECT SIN(PI / 3) AS "sine"
```
Returns the following:

| `sine` |
| -- |
| `0.8660254037844386` |
</details>

[Learn more](sql-scalar.md#numeric-functions)

## SQRT

Expand Down Expand Up @@ -1635,11 +1770,26 @@ Calculates the sum of a set of values.

## TAN

`TAN(expr)`
Calculates the trigonometric tangent of an angle expressed in radians.

**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
* **Syntax:** `TAN(expr)`
* **Function type:** Scalar, numeric

Calculates the trigonometric tangent of an angle expressed in radians.
<details><summary>Example</summary>

The following example calculates the tangent of angle `PI/3` radians.

```sql
SELECT TAN(PI / 3) AS "tangent"
```
Returns the following:

| `tangent` |
| -- |
| `1.7320508075688767` |
</details>

[Learn more](sql-scalar.md#numeric-functions)

## TDIGEST_GENERATE_SKETCH

Expand Down
3 changes: 3 additions & 0 deletions website/.spelling
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ apache.org
AvroStorage
ARN
ASC
arcsine
arccosine
arctangent
autokill
AWS
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
Expand Down

0 comments on commit 028ee23

Please sign in to comment.