Summary
When an endpoint's SQL returns a LIST(STRUCT(...)) column, the REST JSON
response repeats the first struct N times instead of emitting the N distinct
elements. A JSON-typed column (via to_json(...)) serializes correctly, so
the bug is specific to native LIST(STRUCT) serialization.
Repro
Endpoint SQL over a JSON file whose top-level object has an array of objects:
SELECT n_input, by_stage -- by_stage : LIST(STRUCT(stage VARCHAR, reason VARCHAR, n_dropped BIGINT))
FROM read_json('report.json');
DuckDB returns the list correctly:
[{stage: prepare, n_dropped: 11945}, {stage: features, n_dropped: 57203}, {stage: postprocess, n_dropped: 238505}]
But the flapi REST response is:
"by_stage":[{"stage":"prepare","n_dropped":11945},
{"stage":"prepare","n_dropped":11945},
{"stage":"prepare","n_dropped":11945}]
— correct length (3), but every element is element[0].
Workaround
SELECT to_json(by_stage) AS by_stage → flapi emits a correct JSON array
(JSON-typed column path is fine). So the defect is in the LIST(STRUCT) →
JSON conversion in the REST serializer, not the query layer.
Env
flapi-io 26.6.14 (flapi 1.0), DuckDB 1.5.3, Linux. Happy to provide a minimal
config + sample json if useful.
Summary
When an endpoint's SQL returns a
LIST(STRUCT(...))column, the REST JSONresponse repeats the first struct N times instead of emitting the N distinct
elements. A
JSON-typed column (viato_json(...)) serializes correctly, sothe bug is specific to native
LIST(STRUCT)serialization.Repro
Endpoint SQL over a JSON file whose top-level object has an array of objects:
DuckDB returns the list correctly:
But the flapi REST response is:
— correct length (3), but every element is element[0].
Workaround
SELECT to_json(by_stage) AS by_stage→ flapi emits a correct JSON array(JSON-typed column path is fine). So the defect is in the
LIST(STRUCT)→JSON conversion in the REST serializer, not the query layer.
Env
flapi-io 26.6.14 (flapi 1.0), DuckDB 1.5.3, Linux. Happy to provide a minimal
config + sample json if useful.