Skip to content

Commit

Permalink
Minor: improve scalar functions document (#9029)
Browse files Browse the repository at this point in the history
* improve odc
  • Loading branch information
Weijun-H authored Jan 30, 2024
1 parent 851bc7d commit 3eb7080
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 4 deletions.
2 changes: 1 addition & 1 deletion datafusion/expr/src/expr_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ scalar_expr!(
ArrayEmpty,
array_empty,
array,
"returns 1 for an empty array or 0 for a non-empty array."
"returns true for an empty array or false for a non-empty array."
);
scalar_expr!(
ArrayHasAll,
Expand Down
63 changes: 60 additions & 3 deletions docs/source/user-guide/sql/scalar_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -1765,11 +1765,16 @@ from_unixtime(expression)
- [list_dims](#list_dims)
- [list_element](#list_element)
- [list_extract](#list_extract)
- [list_has](#list_has)
- [list_has_all](#list_has_all)
- [list_has_any](#list_has_any)
- [list_indexof](#list_indexof)
- [list_join](#list_join)
- [list_length](#list_length)
- [list_ndims](#list_ndims)
- [list_prepend](#list_prepend)
- [list_pop_back](#list_pop_back)
- [list_pop_front](#list_pop_front)
- [list_position](#list_position)
- [list_positions](#list_positions)
- [list_push_back](#list_push_back)
Expand Down Expand Up @@ -1901,6 +1906,10 @@ array_has(array, element)
- **element**: Scalar or Array expression.
Can be a constant, column, or function, and any combination of array operators.

#### Aliases

- list_has

### `array_has_all`

Returns true if all elements of sub-array exist in array
Expand All @@ -1916,6 +1925,10 @@ array_has_all(array, sub-array)
- **sub-array**: Array expression.
Can be a constant, column, or function, and any combination of array operators.

#### Aliases

- list_has_all

### `array_has_any`

Returns true if any elements exist in both arrays
Expand All @@ -1931,6 +1944,10 @@ array_has_any(array, sub-array)
- **sub-array**: Array expression.
Can be a constant, column, or function, and any combination of array operators.

#### Aliases

- list_has_any

### `array_dims`

Returns an array of the array's dimensions.
Expand Down Expand Up @@ -1990,8 +2007,6 @@ array_element(array, index)
- list_element
- list_extract

### `array_empty`

### `array_extract`

_Alias of [array_element](#array_element)._
Expand Down Expand Up @@ -2150,6 +2165,10 @@ array_pop_front(array)
+-------------------------------+
```

#### Aliases

- list_pop_front

### `array_pop_back`

Returns the array without the last element.
Expand All @@ -2174,6 +2193,10 @@ array_pop_back(array)
+-------------------------------+
```

#### Aliases

- list_pop_back

### `array_position`

Returns the position of the first occurrence of the specified element in the array.
Expand Down Expand Up @@ -2278,6 +2301,10 @@ array_repeat(element, count)
+------------------------------------+
```

#### Aliases

- list_repeat

### `array_remove`

Removes the first element from the array equal to the given value.
Expand Down Expand Up @@ -2459,12 +2486,22 @@ array_replace_all(array, from, to)

### `array_slice`

Returns a slice of the array.
Returns a slice of the array based on 1-indexed start and end positions.

```
array_slice(array, begin, end)
```

#### Arguments

- **array**: Array expression.
Can be a constant, column, or function, and any combination of array operators.
- **begin**: Index of the first element.
If negative, it counts backward from the end of the array.
- **end**: Index of the last element.
If negative, it counts backward from the end of the array.
- **stride**: Stride of the array slice. The default is 1.

#### Example

```
Expand Down Expand Up @@ -2663,6 +2700,18 @@ _Alias of [array_element](#array_element)._

_Alias of [array_element](#array_element)._

### `list_has`

_Alias of [array_has](#array_has)._

### `list_has_all`

_Alias of [array_has_all](#array_has_all)._

### `list_has_any`

_Alias of [array_has_any](#array_has_any)._

### `list_indexof`

_Alias of [array_position](#array_position)._
Expand All @@ -2683,6 +2732,14 @@ _Alias of [array_ndims](#array_ndims)._

_Alias of [array_prepend](#array_prepend)._

### `list_pop_back`

_Alias of [array_pop_back](#array_pop_back)._

### `list_pop_front`

_Alias of [array_pop_front](#array_pop_front)._

### `list_position`

_Alias of [array_position](#array_position)._
Expand Down

0 comments on commit 3eb7080

Please sign in to comment.