Skip to content

Commit

Permalink
minor(docs): Correct array_prepend docs
Browse files Browse the repository at this point in the history
  • Loading branch information
NoeB committed Nov 11, 2024
1 parent be19afc commit e673026
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/source/user-guide/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ select log(-1), log(0), sqrt(-1);
| array_pop_back(array) | Returns the array without the last element. `array_pop_back([1, 2, 3]) -> [1, 2]` |
| array_position(array, element) | Searches for an element in the array, returns first occurrence. `array_position([1, 2, 2, 3, 4], 2) -> 2` |
| array_positions(array, element) | Searches for an element in the array, returns all occurrences. `array_positions([1, 2, 2, 3, 4], 2) -> [2, 3]` |
| array_prepend(array, element) | Prepends an element to the beginning of an array. `array_prepend(1, [2, 3, 4]) -> [1, 2, 3, 4]` |
| array_prepend(element, array) | Prepends an element to the beginning of an array. `array_prepend(1, [2, 3, 4]) -> [1, 2, 3, 4]` |
| array_repeat(element, count) | Returns an array containing element `count` times. `array_repeat(1, 3) -> [1, 1, 1]` |
| array_remove(array, element) | Removes the first element from the array equal to the given value. `array_remove([1, 2, 2, 3, 2, 1, 4], 2) -> [1, 2, 3, 2, 1, 4]` |
| array_remove_n(array, element, max) | Removes the first `max` elements from the array equal to the given value. `array_remove_n([1, 2, 2, 3, 2, 1, 4], 2, 2) -> [1, 3, 2, 1, 4]` |
Expand Down
11 changes: 6 additions & 5 deletions docs/source/user-guide/sql/scalar_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -3081,23 +3081,24 @@ array_position(array, element, index)

### `array_prepend`

Appends an element to the end of an array.
Prepends an element to the beginning of an array.

```
array_append(array, element)
array_prepend(element, array)
```

#### Arguments

- **array**: Array expression. Can be a constant, column, or function, and any combination of array operators.
- **element**: Element to append to the array.
- **array**: Array expression. Can be a constant, column, or function, and any combination of array operators.


#### Example

```sql
> select array_append([1, 2, 3], 4);
> select array_prepend(1, [2, 3, 4]);
+--------------------------------------+
| array_append(List([1,2,3]),Int64(4)) |
| array_prepend(Int64(1), List([2,3,4])) |
+--------------------------------------+
| [1, 2, 3, 4] |
+--------------------------------------+
Expand Down

0 comments on commit e673026

Please sign in to comment.