From 028ee23a1e90446b45952ee78ff3fb0e7ef72123 Mon Sep 17 00:00:00 2001 From: Edgar Melendrez Date: Fri, 26 Jul 2024 13:11:17 -0700 Subject: [PATCH] [Docs] batch 03 - trig functions (#16795) * batch 03 - trig functions * Apply suggestions from code review Co-authored-by: Charles Smith * applying suggestions and corrections --------- Co-authored-by: Charles Smith --- docs/querying/sql-functions.md | 210 ++++++++++++++++++++++++++++----- website/.spelling | 3 + 2 files changed, 183 insertions(+), 30 deletions(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index b04664ac90e3..1b2f68c7a89e 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -70,11 +70,26 @@ Returns the following: ## ACOS -`ACOS()` +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 + +
Example + +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` | +
+ +[Learn more](sql-scalar.md#numeric-functions) ## ANY_VALUE @@ -280,27 +295,72 @@ Joins all elements of `arr` by the delimiter specified by `str`. ## ASIN -`ASIN()` +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 + +
Example + +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` | +
+ +[Learn more](sql-scalar.md#numeric-functions) ## ATAN -`ATAN()` +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 + +
Example -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` | +
+ +[Learn more](sql-scalar.md#numeric-functions) ## ATAN2 -`ATAN2(, )` +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 + +
Example + +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` | +
+ +[Learn more](sql-scalar.md#numeric-functions) ## AVG @@ -514,20 +574,50 @@ Finds whether a string is in a given expression, case-sensitive. ## COS -`COS()` +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. +
Example -## COT +The following example calculates the cosine of angle `PI/3` radians. -`COT()` +```sql +SELECT COS(PI / 3) AS "cosine" +``` +Returns the following: -**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions) +| `cosine` | +| -- | +| `0.5000000000000001` | +
+ +[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 + +
Example + +The following example calculates the cotangent of angle `PI/3` radians. + +```sql +SELECT COT(PI / 3) AS "cotangent" +``` +Returns the following: + +| `cotangent` | +| -- | +| `0.577350269189626` | +
+ +[Learn more](sql-scalar.md#numeric-functions) + ## COUNT `COUNT([DISTINCT] expr)` @@ -589,11 +679,26 @@ Decodes a Base64-encoded string into a UTF-8 encoded string. ## DEGREES -`DEGREES()` +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. +
Example + +The following example converts an angle of `PI` radians to degrees + +```sql +SELECT DEGREES(PI) AS "degrees" +``` +Returns the following: + +| `degrees` | +| -- | +| `180` | +
+ +[Learn more](sql-scalar.md#numeric-functions) ## DENSE_RANK @@ -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) +
Example -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` | +
+ +[Learn more](sql-scalar.md#numeric-functions) ## RANK @@ -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. +
Example + +The following example calculates the sine of angle `PI/3` radians. + +```sql +SELECT SIN(PI / 3) AS "sine" +``` +Returns the following: + +| `sine` | +| -- | +| `0.8660254037844386` | +
+ +[Learn more](sql-scalar.md#numeric-functions) ## SQRT @@ -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. +
Example + +The following example calculates the tangent of angle `PI/3` radians. + +```sql +SELECT TAN(PI / 3) AS "tangent" +``` +Returns the following: + +| `tangent` | +| -- | +| `1.7320508075688767` | +
+ +[Learn more](sql-scalar.md#numeric-functions) ## TDIGEST_GENERATE_SKETCH diff --git a/website/.spelling b/website/.spelling index 4636ea61c901..a80900b3edb9 100644 --- a/website/.spelling +++ b/website/.spelling @@ -31,6 +31,9 @@ apache.org AvroStorage ARN ASC +arcsine +arccosine +arctangent autokill AWS AWS_CONTAINER_CREDENTIALS_RELATIVE_URI