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
{{ message }}
Repository navigation
File creation error when passing output file to COPY TO as a param #382
Using a placeholder for the output file in a COPY TO statement fails if the file does not already exist. Since I get the same error via both Rust and Python, it might not belong in either duckdb-rs or duckdb-python.
(Is a function to SQL escape parameters available via the API?)
To Reproduce
This Python code with an output file name as a param:
importduckdbconn=duckdb.connect()
inp="input.ndjson"out="output.ndjson"conn.execute("COPY (FROM read_json(?)) TO ? (FORMAT JSON)", [inp, out])
fails with:
conn.execute("COPY (FROM read_json(?)) TO ? (FORMAT JSON)", [inp, out])
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_duckdb.IOException: IO Error: No files found that match the pattern "output.ndjson"
LINE 1: COPY (FROM read_json(?)) TO ? (FORMAT JSON)
^
Whereas incorporating the file name into the string works, and tmp.ndjson is created:
safe=out.replace("'", "''")
conn.execute(f"COPY (FROM read_json(?)) TO '{safe}' (FORMAT JSON)", [inp])
It seems that having the output file as a placeholder almost works, but the fopen() mode is perhaps wrong.
OS:
MacOS
DuckDB Package Version:
1.5.0
Python Version:
3.13
Full Name:
James Gilbert
Affiliation:
Wellcome Sanger Institute
What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.
I have tested with a stable release
Did you include all relevant data sets for reproducing the issue?
Not applicable - the reproduction does not require a data set
Did you include all code required to reproduce the issue?
Yes, I have
Did you include all relevant configuration to reproduce the issue?
This seems to be a duckdb core issue related to the multifilereader, which had some changes recently. It reproduces with a prepared statement in the CLI:
DuckDB v1.5.0 (Variegata)
Enter ".help" for usage hints.
memory D PREPARE query_copy AS COPY (FROM read_json(?)) TO ? (FORMAT JSON);
memory D EXECUTE query_copy('example.json', 'output.json');
IO Error:
No files found that match the pattern "output.json"LINE1: EXECUTE query_copy('example.json', 'output.json');
Activity
evertlammerts commentedon Mar 19, 2026
This seems to be a duckdb core issue related to the multifilereader, which had some changes recently. It reproduces with a prepared statement in the CLI:
For the record, the backtrace is:
@szarnyasg can you move this to core?
jgrg commentedon Mar 24, 2026
ping @szarnyasg !
evertlammerts commentedon Mar 24, 2026
I opened a new issue on core to track this: duckdb/duckdb#21578