client.filter_relation

client.filter_relation(relation, where)

Keep the rows of a relation matching a DuckDB SQL expression.

The expression can use the attributes (e.g. POPULATION > 2000) and the geometry column with the functions of the DuckDB spatial extension (e.g. ST_Intersects(geometry, ST_MakeEnvelope(4.2, 43.3, 4.9, 43.8))). On a GeoParquet file, DuckDB applies it while reading.

Parameters

Name Type Description Default
relation duckdb.DuckDBPyRelation Relation, e.g. from read_parquet or read_geojson. required
where str SQL expression, as in a WHERE clause. required

Returns

Name Type Description
duckdb.DuckDBPyRelation

Raises

Name Type Description
ValueError If the expression is not valid SQL, or refers to an unknown column or function.
Retour au sommet