Skip to content

Commit

Permalink
Improve docs for built-in table functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mosabua committed Aug 26, 2024
1 parent 0b9a103 commit 10c7605
Showing 1 changed file with 43 additions and 19 deletions.
62 changes: 43 additions & 19 deletions docs/src/main/sphinx/functions/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,40 @@ documentation](/connector).
## Built-in table functions

(exclude-columns-table-function)=
### `exclude_columns` table function

Use the `exclude_columns` table function to return a new table based on an input
table `table`, with the exclusion of all columns specified in `descriptor`:

:::{function} exclude_columns(input => table, columns => descriptor) -> table
Excludes from `table` all columns listed in `descriptor`:
:noindex: true

The argument `input` is a table or a query.
The argument `columns` is a descriptor without types.
:::

Example query using the orders table from the TPC-H dataset, provided by the
[](/connector/tpch):

```sql
SELECT *
FROM TABLE(exclude_columns(
input => TABLE(orders),
columns => DESCRIPTOR(clerk, comment)))
columns => DESCRIPTOR(clerk, comment)));
```

The argument `input` is a table or a query.
The argument `columns` is a descriptor without types.
:::
The table function is useful for queries where you want to return nearly all
columns from tables with many columns. You can avoid enumerating all columns,
and only need to specify the columns to exclude.

(sequence-table-function)=
:::{function} sequence(start => bigint, stop => bigint, step => bigint) -> table(sequential_number bigint)
:noindex: true
### `sequence` table function

Returns a single column `sequential_number` containing a sequence of
bigint:
Use the `sequence` table function to return a table with a single column
`sequential_number` containing a sequence of bigint:

```sql
SELECT *
FROM TABLE(sequence(
start => 1000000,
stop => -2000000,
step => -3))
```
:::{function} sequence(start => bigint, stop => bigint, step => bigint) -> table(sequential_number bigint)
:noindex: true

`start` is the first element in the sequence. The default value is `0`.

Expand All @@ -69,9 +75,27 @@ reachable by steps.
`1`.
:::

:::{note}
The result of the `sequence` table function might not be ordered.
:::
Example query:

```sql
SELECT *
FROM TABLE(sequence(
start => 1000000,
stop => -2000000,
step => -3));
```

The result of the `sequence` table function might not be ordered. If required,
enforce ordering in the enclosing query:

```sql
SELECT *
FROM TABLE(sequence(
start => 0,
stop => 100,
step => 5))
ORDER BY sequential_number;
```

## Table function invocation

Expand Down

0 comments on commit 10c7605

Please sign in to comment.