Skip to content

Commit 5573a98

Browse files
committed
fix columns options
1 parent 4a1ad0e commit 5573a98

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

docs/summary-table.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ SELECT cos(range * pi() / 10) as x, sin(range * pi() / 10) as y FROM range(0, 20
3636
const sql = DuckDBClient.sql({aapl, penguins, gaia: FileAttachment("/lib/gaia-sample.parquet")});
3737
```
3838

39+
```js echo
40+
display(Inputs.table(await sql`SELECT * FROM aapl`, {columns: ["Date", "Open"]}));
41+
```
42+
3943
```js echo
4044
import * as _Inputs from "npm:@observablehq/inputs"
4145
import * as Arrow from "npm:apache-arrow";
@@ -54,7 +58,7 @@ function table(data, options = {}) {
5458
if (!Array.isArray(data?.schema?.fields)) return container;
5559

5660
// Get the fields as described by Arrow, in the order given (potentially) by the options.
57-
const fields = (options.columns?.map(k => data.schema.find(({name}) => name === k)) ?? data.schema.fields).map(({name, type}) => ({name: String(name), type: String(type), values: data.getChild(name)}));
61+
const fields = (options.columns?.map(k => data.schema.fields.find(({name}) => name === k)) ?? data.schema.fields).map(({name, type}) => ({name: String(name), type: String(type), values: data.getChild(name)}));
5862

5963
options.columns = fields.map(({name}) => name);
6064

0 commit comments

Comments
 (0)