Skip to content

Commit 8cc825d

Browse files
authored
Merge pull request #5714 from soerenwolfers/patch-226778
Update from.md
2 parents 8cc7c4a + a1bbb8a commit 8cc825d

File tree

1 file changed

+27
-0
lines changed
  • docs/preview/sql/query_syntax

1 file changed

+27
-0
lines changed

docs/preview/sql/query_syntax/from.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,33 @@ SELECT sum(t.i)
119119
WHERE i % 2 = 0;
120120
```
121121

122+
### Table Functions
123+
124+
Some functions in duckdb return entire tables rather than individual values. These functions are accordingly called _table functions_ and can be used with a `FROM` clause like regular table references.
125+
Examples include `read_csv`, `read_parquet`, `range`, `generate_series`, `repeat`, `unnest`, `glob`. For example, the previous example
126+
127+
```sql
128+
SELECT *
129+
FROM 'test.csv';
130+
```
131+
132+
is implicitly translated to
133+
134+
135+
```sql
136+
SELECT *
137+
FROM read_csv('test.csv');
138+
```
139+
140+
All table functions support a `WITH ORDINALITY` prefix, which extends the returned table by an integer column `ordinality` that enumerates the generated rows starting at `1`.
141+
142+
```sql
143+
SELECT *
144+
FROM read_csv('test.csv') WITH ORDINALITY;
145+
```
146+
147+
Note that the same result could be achieved using the `row_number` window function.
148+
122149
## Joins
123150

124151
Joins are a fundamental relational operation used to connect two tables or relations horizontally.

0 commit comments

Comments
 (0)