liveBook · Manning

Table function

As explained in DuckDB in Action

A table function is a callable query component that returns a relation consisting of rows and columns.

A table function is a callable query component that returns rows and columns, letting SQL read or generate relation-shaped data. DuckDB uses functions such as read_csv_auto and read_parquet to inspect external files and feed their results into queries or INSERT statements. section 3.4.1

Load a remote CSV into a table

INSERT INTO readings(system_id, read_on, power) SELECT SiteId, "Date-Time", CASE WHEN ac_power < 0 OR ac_power IS NULL THEN 0 ELSE ac_power END FROM read_csv_auto('https://developer.nrel.gov/api/pvdaq/v3/data_file?api_key=DEMO_KEY&system_id=34&year=2019'); Here, read_csv_auto supplies the input relation, while SELECT transforms its columns before insertion. section 3.4.1

INSERT INTO prices
VALUES (1, 11.59, '2018-12-01', '2019-01-01');

Inspect the attempted dynamic-file query, which combines range-generated URLs with read_csv_auto and exposes table-function parameter restrictions. section 3.4.1

How DuckDB in Action covers it

How deep it goes
Explains file-backed usage and schema discovery, then stops at DuckDB’s constant-parameter restriction and its chicken-and-egg consequence.
Examples
Demonstrates read_csv_auto for remote photovoltaic readings and a range-generated list of CSV URLs.
What it assumes
Assumes basic SQL querying and relations while demonstrating external-file ingestion through concrete INSERT and SELECT workflows.
What you can do after
Apply it via DuckDB table functions to ingest external files and recognize when dynamic parameters will fail.
How it connects
Connects table functions with range functions, inline tables, views, INSERT statements, and schema inference.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of DuckDB in Action. The section links point to the parts of the book it draws on.