Skip to content

Commit 84b327c

Browse files
Adez017Jefffrey
andauthored
doc: add missing examples for multiple math functions (#17018)
* Update Scalar_functions.md * pretier fix * Updated files * Updated Scalar functions * Update datafusion/functions/src/math/log.rs Co-authored-by: Jeffrey Vo <[email protected]> * Update datafusion/functions/src/math/monotonicity.rs Co-authored-by: Jeffrey Vo <[email protected]> * Update datafusion/functions/src/math/monotonicity.rs Co-authored-by: Jeffrey Vo <[email protected]> * Update datafusion/functions/src/math/nans.rs Co-authored-by: Jeffrey Vo <[email protected]> * Update datafusion/functions/src/math/nanvl.rs Co-authored-by: Jeffrey Vo <[email protected]> * Fix tanh example to be tanh not trunc * Run update_function_docs.sh --------- Co-authored-by: Jeffrey Vo <[email protected]>
1 parent 23d91c5 commit 84b327c

File tree

16 files changed

+741
-15
lines changed

16 files changed

+741
-15
lines changed

datafusion/functions/src/math/abs.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ fn create_abs_function(input_data_type: &DataType) -> Result<MathArrayFunction>
108108
doc_section(label = "Math Functions"),
109109
description = "Returns the absolute value of a number.",
110110
syntax_example = "abs(numeric_expression)",
111+
sql_example = r#"```sql
112+
> SELECT abs(-5);
113+
+----------+
114+
| abs(-5) |
115+
+----------+
116+
| 5 |
117+
+----------+
118+
```"#,
111119
standard_argument(name = "numeric_expression", prefix = "Numeric")
112120
)]
113121
#[derive(Debug, PartialEq, Eq, Hash)]

datafusion/functions/src/math/cot.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ use datafusion_macros::user_doc;
3232
doc_section(label = "Math Functions"),
3333
description = "Returns the cotangent of a number.",
3434
syntax_example = r#"cot(numeric_expression)"#,
35+
sql_example = r#"```sql
36+
> SELECT cot(1);
37+
+---------+
38+
| cot(1) |
39+
+---------+
40+
| 0.64209 |
41+
+---------+
42+
```"#,
3543
standard_argument(name = "numeric_expression", prefix = "Numeric")
3644
)]
3745
#[derive(Debug, PartialEq, Eq, Hash)]

datafusion/functions/src/math/factorial.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ use datafusion_macros::user_doc;
3737
doc_section(label = "Math Functions"),
3838
description = "Factorial. Returns 1 if value is less than 2.",
3939
syntax_example = "factorial(numeric_expression)",
40+
sql_example = r#"```sql
41+
> SELECT factorial(5);
42+
+---------------+
43+
| factorial(5) |
44+
+---------------+
45+
| 120 |
46+
+---------------+
47+
```"#,
4048
standard_argument(name = "numeric_expression", prefix = "Numeric")
4149
)]
4250
#[derive(Debug, PartialEq, Eq, Hash)]

datafusion/functions/src/math/gcd.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ use datafusion_macros::user_doc;
3434
doc_section(label = "Math Functions"),
3535
description = "Returns the greatest common divisor of `expression_x` and `expression_y`. Returns 0 if both inputs are zero.",
3636
syntax_example = "gcd(expression_x, expression_y)",
37+
sql_example = r#"```sql
38+
> SELECT gcd(48, 18);
39+
+------------+
40+
| gcd(48,18) |
41+
+------------+
42+
| 6 |
43+
+------------+
44+
```"#,
3745
standard_argument(name = "expression_x", prefix = "First numeric"),
3846
standard_argument(name = "expression_y", prefix = "Second numeric")
3947
)]

datafusion/functions/src/math/iszero.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ use crate::utils::make_scalar_function;
3636
doc_section(label = "Math Functions"),
3737
description = "Returns true if a given number is +0.0 or -0.0 otherwise returns false.",
3838
syntax_example = "iszero(numeric_expression)",
39+
sql_example = r#"```sql
40+
> SELECT iszero(0);
41+
+------------+
42+
| iszero(0) |
43+
+------------+
44+
| true |
45+
+------------+
46+
```"#,
3947
standard_argument(name = "numeric_expression", prefix = "Numeric")
4048
)]
4149
#[derive(Debug, PartialEq, Eq, Hash)]

datafusion/functions/src/math/lcm.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ use crate::utils::make_scalar_function;
3737
doc_section(label = "Math Functions"),
3838
description = "Returns the least common multiple of `expression_x` and `expression_y`. Returns 0 if either input is zero.",
3939
syntax_example = "lcm(expression_x, expression_y)",
40+
sql_example = r#"```sql
41+
> SELECT lcm(4, 5);
42+
+----------+
43+
| lcm(4,5) |
44+
+----------+
45+
| 20 |
46+
+----------+
47+
```"#,
4048
standard_argument(name = "expression_x", prefix = "First numeric"),
4149
standard_argument(name = "expression_y", prefix = "Second numeric")
4250
)]

datafusion/functions/src/math/log.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ use datafusion_macros::user_doc;
4848
description = "Returns the base-x logarithm of a number. Can either provide a specified base, or if omitted then takes the base-10 of a number.",
4949
syntax_example = r#"log(base, numeric_expression)
5050
log(numeric_expression)"#,
51+
sql_example = r#"```sql
52+
> SELECT log(10);
53+
+---------+
54+
| log(10) |
55+
+---------+
56+
| 1.0 |
57+
+---------+
58+
```"#,
5159
standard_argument(name = "base", prefix = "Base numeric"),
5260
standard_argument(name = "numeric_expression", prefix = "Numeric")
5361
)]

0 commit comments

Comments
 (0)