I cannot pass a direct FastAPI response like JSON/ORJSONResponse as an output for the FastAPI route; when I do, the first response is correct, but then the first cache HIT is double encoded.
The double encoded data comes if the return object is like:
return ORJSONResponse(content=result)
The result object is a list of dicts result = lf.collect().to_dicts(). This turns a LazyFrame into a list of dicts list[dict[str, Any]] .
If I pass the object directly then it works, but how can I pass the direct response, to bypass FastAPIs encoding or passing the custom ORJSONResponse so that the encoding engine uses orjson and not just json
I cannot pass a direct FastAPI response like
JSON/ORJSONResponse
as an output for the FastAPI route; when I do, the first response is correct, but then the first cache HIT is double encoded.Setup
The double encoded data comes if the return object is like:
The result object is a list of dicts
result = lf.collect().to_dicts()
. This turns a LazyFrame into a list of dictslist[dict[str, Any]]
.If I pass the object directly then it works, but how can I pass the direct response, to bypass FastAPIs encoding or passing the custom
ORJSONResponse
so that the encoding engine usesorjson
and not justjson