Skip to content

Commit feac75c

Browse files
committed
Set builder on indirect's primitive composer for CTE execution
The dependency planner path was setting the builder on pChild's primitive composer, but not on pb.PrimitiveComposer (the indirect's composer). When parent's GetBuilder() iterates over indirects to create the diamond builder, it calls GetBuilder() on each indirect's primitive composer - which was nil for CTEs. This fix ensures the builder is also set on the indirect's primitive composer so the CTE's inner SELECT builder gets included in the execution graph, allowing the API calls to execute and populate SQLite tables with data.
1 parent 9dfded5 commit feac75c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

internal/stackql/primitivegenerator/select.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ func (pb *standardPrimitiveGenerator) analyzeSelect(pbi planbuilderinput.PlanBui
224224
selCtx := dp.GetSelectCtx()
225225
pChild.GetPrimitiveComposer().SetBuilder(bld)
226226
pb.PrimitiveComposer.SetSelectPreparedStatementCtx(selCtx)
227+
// For indirects (like CTEs), also set the builder on the indirect's primitive
228+
// composer so it can be found when parent's GetBuilder() iterates over indirects.
229+
if pb.PrimitiveComposer.IsIndirect() {
230+
pb.PrimitiveComposer.SetBuilder(bld)
231+
}
227232
return nil
228233
}
229234
}

0 commit comments

Comments
 (0)