Jefffrey commented on code in PR #17018:
URL: https://github.com/apache/datafusion/pull/17018#discussion_r2347671241
##########
datafusion/functions/src/math/monotonicity.rs:
##########
@@ -309,6 +416,16 @@ static DOCUMENTATION_DEGREES: LazyLock<Documentation> =
LazyLock::new(|| {
"degrees(numeric_expression)",
)
.with_standard_argument("numeric_expression", Some("Numeric"))
+ .with_sql_example(
+ r#"```sql
+ > SELECT degrees(pi());
++------------+
+| degrees(0) |
++------------+
+| 0.0 |
++------------+
Review Comment:
```suggestion
> SELECT degrees(pi());
+------------+
| degrees(0) |
+------------+
| 180.0 |
+------------+
```
##########
datafusion/functions/src/math/monotonicity.rs:
##########
@@ -471,6 +648,16 @@ static DOCUMENTATION_SIN: LazyLock<Documentation> =
LazyLock::new(|| {
"sin(numeric_expression)",
)
.with_standard_argument("numeric_expression", Some("Numeric"))
+ .with_sql_example(
+ r#"```sql
+> SELECT sin(0);
++----------+
+| sin(0) |
++----------+
+| 1.0 |
++----------+
Review Comment:
```suggestion
> SELECT sin(0);
+----------+
| sin(0) |
+----------+
| 0.0 |
+----------+
```
##########
datafusion/functions/src/math/monotonicity.rs:
##########
@@ -558,6 +765,16 @@ static DOCUMENTATION_TANH: LazyLock<Documentation> =
LazyLock::new(|| {
"tanh(numeric_expression)",
)
.with_standard_argument("numeric_expression", Some("Numeric"))
+ .with_sql_example(
+ r#" ```sql
+ > SELECT trunc(42.738);
+ +----------------+
+ | trunc(42.738) |
+ +----------------+
+ | 42 |
+ +----------------+
Review Comment:
This should be tanh not trunc
##########
datafusion/functions/src/math/log.rs:
##########
@@ -42,6 +42,14 @@ use datafusion_macros::user_doc;
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.",
syntax_example = r#"log(base, numeric_expression)
log(numeric_expression)"#,
+ sql_example = r#"```sql
+> SELECT log(2.71828);
++--------------+
+| log(2.71828) |
++--------------+
+| 1.0 |
++--------------+
Review Comment:
```suggestion
> SELECT log(10);
+---------+
| log(10) |
+---------+
| 1.0 |
+---------+
```
Default base is 10
##########
datafusion/functions/src/math/nans.rs:
##########
@@ -31,6 +31,14 @@ use std::sync::Arc;
doc_section(label = "Math Functions"),
description = "Returns true if a given number is +NaN or -NaN otherwise
returns false.",
syntax_example = "isnan(numeric_expression)",
+ sql_example = r#"```sql
+> SELECT isnan(1);
++----------+
+| isnan(1) |
++----------+
+| true |
++----------+
Review Comment:
```suggestion
> SELECT isnan(1);
+----------+
| isnan(1) |
+----------+
| false |
+----------+
```
##########
datafusion/functions/src/math/nanvl.rs:
##########
@@ -36,6 +36,14 @@ use datafusion_macros::user_doc;
description = r#"Returns the first argument if it's not _NaN_.
Returns the second argument otherwise."#,
syntax_example = "nanvl(expression_x, expression_y)",
+ sql_example = r#"```sql
+> SELECT nanvl( 0, 5);
++------------+
+| nanvl(0,5) |
++------------+
+| 5 |
++------------+
Review Comment:
```suggestion
> SELECT nanvl(0, 5);
+------------+
| nanvl(0,5) |
+------------+
| 0 |
+------------+
```
##########
docs/source/user-guide/sql/scalar_functions.md:
##########
@@ -527,6 +901,17 @@ tanh(numeric_expression)
- **numeric_expression**: Numeric expression to operate on. Can be a constant,
column, or function, and any combination of operators.
+#### Example
+
+```sql
+> SELECT trunc(42.738);
Review Comment:
This is due to trunc being accidentally used in the sql doc example instead
of tanh, see my other comments
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]