duckdb / pg_duckdb

DuckDB-powered Postgres for high performance apps & analytics.
MIT License
1.25k stars 48 forks source link

Misleading error when using `read_xxx` functions with invalid URLs #106

Open Y-- opened 1 month ago

Y-- commented 1 month ago

I get ERROR: Function `read_csv(TEXT)` only works with Duckdb execution. when using read_csv (along with the actual error as a warning):

y=# SELECT * from read_csv('https://www.data.gouv.fr/fr/datasets/r/6d186965-f41b-41f3-9b23-88241cc6890c') as (n int);
WARNING:  (DuckDB) HTTP Error: Unable to connect to URL "https://www.data.gouv.fr/fr/datasets/r/6d186965-f41b-41f3-9b23-88241cc6890c": 404 (Not Found)
ERROR:  Function `read_csv(TEXT)` only works with Duckdb execution.
CONTEXT:  PL/pgSQL function read_csv(text) line 3 at RAISE

I would expect the WARNING to be the ERROR and the ERROR to not show.

JelteF commented 1 month ago

Once we merge #123 we can use/cache the NeedsDuckdbExecution function and fail with an ERROR instead of WARNING when execution in DuckDB fails. i.e. for queries where NeedsDuckdbExecution returns true there's no point in retrying the query in postgres.