alamb commented on code in PR #12948:
URL: https://github.com/apache/datafusion/pull/12948#discussion_r1802076218
##########
docs/source/user-guide/sql/scalar_functions.md:
##########
@@ -2078,52 +669,6 @@ Transforms an array into rows.
+-----------------------------------+
```
-### `range`
-
-Returns an Arrow array between start and stop with step. `SELECT range(2, 10,
3) -> [2, 5, 8]` or `SELECT range(DATE '1992-09-01', DATE '1993-03-01',
INTERVAL '1' MONTH);`
-
-The range start..end contains all values with start <= x < end. It is empty if
start >= end.
-
-Step can not be 0 (then the range will be nonsense.).
-
-Note that when the required range is a number, it accepts (stop), (start,
stop), and (start, stop, step) as parameters, but when the required range is a
date or timestamp, it must be 3 non-NULL parameters.
-For example,
-
-```
-SELECT range(3);
-SELECT range(1,5);
-SELECT range(1,5,1);
-```
-
-are allowed in number ranges
-
-but in date and timestamp ranges, only
-
-```
-SELECT range(DATE '1992-09-01', DATE '1993-03-01', INTERVAL '1' MONTH);
-SELECT range(TIMESTAMP '1992-09-01', TIMESTAMP '1993-03-01', INTERVAL '1'
MONTH);
-```
-
-is allowed, and
-
-```
-SELECT range(DATE '1992-09-01', DATE '1993-03-01', NULL);
-SELECT range(NULL, DATE '1993-03-01', INTERVAL '1' MONTH);
-SELECT range(DATE '1992-09-01', NULL, INTERVAL '1' MONTH);
-```
-
-are not allowed
-
-#### Arguments
-
-- **start**: start of the range. Ints, timestamps, dates or string types that
can be coerced to Date32 are supported.
-- **end**: end of the range (not included). Type must be the same as start.
-- **step**: increase by step (can not be 0). Steps less than a day are
supported only for timestamp ranges.
-
-#### Aliases
-
-- generate_series
-
## Struct Functions
- [unnest](#unnest-struct)
Review Comment:
I think `unnest` is special and not a scalar function. Perhaps as a follow
on PR we can make a new page called "Special Functions" and put it there.
##########
datafusion/functions-nested/src/extract.rs:
##########
@@ -314,6 +354,49 @@ impl ScalarUDFImpl for ArraySlice {
fn aliases(&self) -> &[String] {
&self.aliases
}
+
+ fn documentation(&self) -> Option<&Documentation> {
+ Some(get_array_slice_doc())
+ }
+}
+
+fn get_array_slice_doc() -> &'static Documentation {
+ DOCUMENTATION.get_or_init(|| {
+ Documentation::builder()
+ .with_doc_section(DOC_SECTION_ARRAY)
+ .with_description(
+ "Returns a slice of the array based on 1-indexed start and end
positions.",
+ )
+ .with_syntax_example("array_slice(array, begin, end)")
Review Comment:
this example doesn't include `stride` but that is probably ok
##########
datafusion/functions-nested/src/make_array.rs:
##########
@@ -149,6 +153,39 @@ impl ScalarUDFImpl for MakeArray {
)
}
}
+
+ fn documentation(&self) -> Option<&Documentation> {
+ Some(get_make_array_doc())
+ }
+}
+
+static DOCUMENTATION: OnceLock<Documentation> = OnceLock::new();
+
+fn get_make_array_doc() -> &'static Documentation {
+ DOCUMENTATION.get_or_init(|| {
+ Documentation::builder()
+ .with_doc_section(DOC_SECTION_ARRAY)
+ .with_description(
+ "Returns an Arrow array using the specified input
expressions.",
Review Comment:
I think `Arrow` is superflous, though I suspect it came from the original
text and is not incorrect. It might be clearer to omit
```suggestion
"Returns an array using the specified input expressions.",
```
##########
datafusion/functions-nested/src/flatten.rs:
##########
@@ -95,6 +98,38 @@ impl ScalarUDFImpl for Flatten {
fn aliases(&self) -> &[String] {
&self.aliases
}
+
+ fn documentation(&self) -> Option<&Documentation> {
+ Some(get_flatten_doc())
+ }
+}
+static DOCUMENTATION: OnceLock<Documentation> = OnceLock::new();
+
+fn get_flatten_doc() -> &'static Documentation {
Review Comment:
this is so nice to have this documentation as part of the function
--
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]