Skip to content

Commit bf1f8ec

Browse files
Update from.md
1 parent 020d8a8 commit bf1f8ec

File tree

1 file changed

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

1 file changed

+29
-0
lines changed

docs/preview/sql/query_syntax/from.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,35 @@ 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+
128+
```sql
129+
SELECT *
130+
FROM 'test.csv';
131+
```
132+
133+
is implicitly translated to
134+
135+
136+
```sql
137+
SELECT *
138+
FROM read_csv('test.csv');
139+
```
140+
141+
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`.
142+
143+
```sql
144+
SELECT *
145+
FROM read_csv('test.csv') WITH ORDINALITY;
146+
```
147+
148+
Note that the same result could be achieved using the `row_number` window function.
149+
150+
122151
## Joins
123152

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

0 commit comments

Comments
 (0)