Skip to content

Commit

Permalink
Add docs for SRF column accessors
Browse files Browse the repository at this point in the history
Fixes #3070.
  • Loading branch information
rmloveland committed Oct 8, 2018
1 parent 9a7dcc6 commit 9f55e1c
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions v2.1/table-expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ For example:

{% include copy-clipboard.html %}
~~~ sql
> SELECT * FROM generate_series(1, 3)
> SELECT * FROM generate_series(1, 3);
~~~
~~~
+-----------------+
Expand All @@ -198,7 +198,30 @@ For example:
+-----------------+
~~~

{{site.data.alerts.callout_info}}Currently CockroachDB only supports a small set of generator function compatible with <a href="https://www.postgresql.org/docs/9.6/static/functions-srf.html">the PostgreSQL set-generating functions of the same name</a>.{{site.data.alerts.end}}
<span class="version-tag">New in v2.1:</span> Set-returning functions (SRFs) can now be accessed using `(SRF).x` where `x` is one of the following:

- The name of a column returned from the function
- `*` to denote all columns.

For example (note that the output of queries against [`information_schema`](information-schema.html) will vary per database):

{% include copy-clipboard.html %}
~~~ sql
> SELECT (i.keys).* FROM (SELECT information_schema._pg_expandarray(indkey) AS keys FROM pg_index) AS i;
~~~

~~~
x | n
---+---
1 | 1
2 | 1
(2 rows)
~~~

{{site.data.alerts.callout_info}}
Currently CockroachDB only supports a small set of generator functions compatible with [the PostgreSQL set-generating functions with the same
names](https://www.postgresql.org/docs/9.6/static/functions-srf.html).
{{site.data.alerts.end}}

## Operators that extend a table expression

Expand Down

0 comments on commit 9f55e1c

Please sign in to comment.