diff --git a/docs/preview/sql/query_syntax/from.md b/docs/preview/sql/query_syntax/from.md index 9ddfc3f738b..0ebe431a0ad 100644 --- a/docs/preview/sql/query_syntax/from.md +++ b/docs/preview/sql/query_syntax/from.md @@ -119,6 +119,35 @@ SELECT sum(t.i) WHERE i % 2 = 0; ``` +### Table functions + +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. +Examples include `read_csv`, `read_parquet`, `range`, `generate_series`, `repeat`, `unnest`, `glob`. For example, the previous example + + +```sql +SELECT * +FROM 'test.csv'; +``` + +is implicitly translated to + + +```sql +SELECT * +FROM read_csv('test.csv'); +``` + +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`. + +```sql +SELECT * +FROM read_csv('test.csv') WITH ORDINALITY; +``` + +Note that the same result could be achieved using the `row_number` window function. + + ## Joins Joins are a fundamental relational operation used to connect two tables or relations horizontally.