If you already know the schema, you could create the duckdb table with an explicit schema rather than having it inferred, or cast the columns on the select?
CREATE TABLE temp_data ();
INSERT INTO temp_data SELECT * FROM read_json_auto('${path}');
CREATE OR REPLACE TABLE temp_data AS
SELECT cast(x as a), cast(y as b) FROM read_json_auto('${path}');