You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/functions.md
+65-19Lines changed: 65 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,8 @@ Note: `ALTER EXTENSION pg_duckdb WITH SCHEMA schema` is not currently supported.
29
29
| Name | Description |
30
30
| :--- | :---------- |
31
31
|[`duckdb.install_extension`](#install_extension)| Installs a DuckDB extension |
32
-
|[`duckdb.raw_query`](#raw_query)| Runs a query directly against DuckDB (meant for debugging)|
32
+
|[`duckdb.query`](#query)| Runs a SELECT query directly against DuckDB |
33
+
|[`duckdb.raw_query`](#raw_query)| Runs any query directly against DuckDB (meant for debugging)|
33
34
|[`duckdb.recycle_ddb`](#recycle_ddb)| Force a reset the DuckDB instance in the current connection (meant for debugging) |
34
35
35
36
## Motherduck Functions
@@ -40,14 +41,16 @@ Note: `ALTER EXTENSION pg_duckdb WITH SCHEMA schema` is not currently supported.
40
41
41
42
## Detailed Descriptions
42
43
43
-
#### <aname="read_parquet"></a>`read_parquet(path TEXT or TEXT[], /* optional parameters */) -> SETOF record`
44
+
#### <aname="read_parquet"></a>`read_parquet(path TEXT or TEXT[], /* optional parameters */) -> SETOF duckdb.row`
44
45
45
46
Reads a parquet file, either from a remote location (via httpfs) or a local file.
46
47
47
-
Returns a record set (`SETOF record`). Functions that return record sets need to have their columns and types specified using `AS`. You must specify at least one column and any columns used in your query. For example:
48
+
This returns DuckDB rows, you can expand them using `*` or you can select specific columns using the `r['mycol']` syntax. If you want to select specific columns you should give the function call an easy alias, like `r`. For example:
48
49
49
50
```sql
50
-
SELECTCOUNT(i) FROM read_parquet('file.parquet') AS (int i);
51
+
SELECT*FROM read_parquet('file.parquet');
52
+
SELECT r['id'], r['name'] FROM read_parquet('file.parquet') r WHERE r['age'] >21;
53
+
SELECTCOUNT(*) FROM read_parquet('file.parquet');
51
54
```
52
55
53
56
Further information:
@@ -65,14 +68,16 @@ Further information:
65
68
66
69
Optional parameters mirror [DuckDB's read_parquet function](https://duckdb.org/docs/data/parquet/overview.html#parameters). To specify optional parameters, use `parameter := 'value'`.
67
70
68
-
#### <aname="read_csv"></a>`read_csv(path TEXT or TEXT[], /* optional parameters */) -> SETOF record`
71
+
#### <aname="read_csv"></a>`read_csv(path TEXT or TEXT[], /* optional parameters */) -> SETOF duckdb.row`
69
72
70
73
Reads a CSV file, either from a remote location (via httpfs) or a local file.
71
74
72
-
Returns a record set (`SETOF record`). Functions that return record sets need to have their columns and types specified using `AS`. You must specify at least one column and any columns used in your query. For example:
75
+
This returns DuckDB rows, you can expand them using `*` or you can select specific columns using the `r['mycol']` syntax. If you want to select specific columns you should give the function call an easy alias, like `r`. For example:
73
76
74
77
```sql
75
-
SELECTCOUNT(i) FROM read_csv('file.csv') AS (int i);
78
+
SELECT*FROM read_csv('file.csv');
79
+
SELECT r['id'], r['name'] FROM read_csv('file.csv') r WHERE r['age'] >21;
80
+
SELECTCOUNT(*) FROM read_csv('file.csv');
76
81
```
77
82
78
83
Further information:
@@ -95,14 +100,16 @@ Compatibility notes:
95
100
*`columns` is not currently supported.
96
101
*`nullstr` must be an array (`TEXT[]`).
97
102
98
-
#### <aname="read_json"></a>`read_json(path TEXT or TEXT[], /* optional parameters */) -> SETOF record`
103
+
#### <aname="read_json"></a>`read_json(path TEXT or TEXT[], /* optional parameters */) -> SETOF duckdb.row`
99
104
100
105
Reads a JSON file, either from a remote location (via httpfs) or a local file.
101
106
102
-
Returns a record set (`SETOF record`). Functions that return record sets need to have their columns and types specified using `AS`. You must specify at least one column and any columns used in your query. For example:
107
+
This returns DuckDB rows, you can expand them using `*` or you can select specific columns using the `r['mycol']` syntax. If you want to select specific columns you should give the function call an easy alias, like `r`. For example:
103
108
104
109
```sql
105
-
SELECTCOUNT(i) FROM read_json('file.json') AS (int i);
110
+
SELECT*FROM read_parquet('file.parquet');
111
+
SELECT r['id'], r['name'] FROM read_parquet('file.parquet') r WHERE r['age'] >21;
Reads an Iceberg table, either from a remote location (via httpfs) or a local directory.
129
136
@@ -133,10 +140,12 @@ To use `iceberg_scan`, you must enable the `iceberg` extension:
133
140
SELECTduckdb.install_extension('iceberg');
134
141
```
135
142
136
-
Returns a record set (`SETOF record`). Functions that return record sets need to have their columns and types specified using `AS`. You must specify at least one column and any columns used in your query. For example:
143
+
This returns DuckDB rows, you can expand them using `*` or you can select specific columns using the `r['mycol']` syntax. If you want to select specific columns you should give the function call an easy alias, like `r`. For example:
137
144
138
145
```sql
139
-
SELECTCOUNT(i) FROM iceberg_scan('data/iceberg/table') AS (int i);
146
+
SELECT*FROM iceberg_scan('data/iceberg/table');
147
+
SELECT r['id'], r['name'] FROM iceberg_scan('data/iceberg/table') r WHERE r['age'] >21;
148
+
SELECTCOUNT(*) FROM iceberg_scan('data/iceberg/table');
140
149
```
141
150
142
151
Further information:
@@ -209,22 +218,25 @@ Optional parameters mirror DuckDB's `iceberg_metadata` function based on the Duc
Reads a delta dataset, either from a remote (via httpfs) or a local location.
215
224
216
-
Returns a record set (`SETOF record`). Functions that return record sets need to have their columns and types specified using `AS`. You must specify at least one column and any columns used in your query. For example:
217
-
218
225
To use `delta_scan`, you must enable the `delta` extension:
219
226
220
227
```sql
221
228
SELECTduckdb.install_extension('delta');
222
229
```
223
230
231
+
This returns DuckDB rows, you can expand them using `*` or you can select specific columns using the `r['mycol']` syntax. If you want to select specific columns you should give the function call an easy alias, like `r`. For example:
232
+
224
233
```sql
225
-
SELECTCOUNT(i) FROM delta_scan('/path/to/delta/dataset') AS (int i);
234
+
SELECT*FROM delta_scan('/path/to/delta/dataset');
235
+
SELECT r['id'], r['name'] FROM delta_scan('/path/to/delta/dataset') r WHERE r['age'] >21;
236
+
SELECTCOUNT(*) FROM delta_scan('/path/to/delta/dataset');
0 commit comments