Description
A named WINDOW w AS (...) clause on a CLUSTER/MERGE query, referenced by a surviving projection (SUM(score) OVER w), is not carried through the whole-query rewrite. As of #181, giql.expanders._genomic.transplant raises a clear ValueError for it (rather than the earlier silent drop that emitted a dangling OVER w → non-executable SQL). This issue tracks supporting it instead of rejecting it.
SELECT SUM(score) OVER w AS s, CLUSTER(interval) AS cid FROM peaks WINDOW w AS (PARTITION BY chrom)
Motivation
WINDOW is standard SQL supported by DuckDB and DataFusion. A dropped/rejected WINDOW is the same non-executable failure class as the dropped WITH (#174). It was deliberately left out of #181's scope because preserving it correctly is not a simple outer re-attach.
Root cause / why it is not a one-line fix
CLUSTER duplicates the user's non-CLUSTER projections into both the inner __giql_lag_calc subquery (so the columns are available to the window/adjacency computation) and the outer query. A SUM(score) OVER w projection therefore appears at both levels, so the WINDOW w AS (...) definition must be threaded into the inner subquery too — an outer-only re-attach (the mechanism _PRESERVED_ROOT_ARGS uses for LIMIT/OFFSET/DISTINCT/QUALIFY) leaves the inner OVER w dangling. MERGE has an analogous inner/outer split.
Expected outcome
A CLUSTER/MERGE query carrying a named WINDOW clause referenced by a surviving projection transpiles to executable SQL that defines the window at whatever level(s) reference it, rather than raising. Until then the #181 ValueError is the correct interim behavior (loud, not silent).
Description
A named
WINDOW w AS (...)clause on a CLUSTER/MERGE query, referenced by a surviving projection (SUM(score) OVER w), is not carried through the whole-query rewrite. As of #181,giql.expanders._genomic.transplantraises a clearValueErrorfor it (rather than the earlier silent drop that emitted a danglingOVER w→ non-executable SQL). This issue tracks supporting it instead of rejecting it.Motivation
WINDOWis standard SQL supported by DuckDB and DataFusion. A dropped/rejected WINDOW is the same non-executable failure class as the droppedWITH(#174). It was deliberately left out of #181's scope because preserving it correctly is not a simple outer re-attach.Root cause / why it is not a one-line fix
CLUSTER duplicates the user's non-CLUSTER projections into both the inner
__giql_lag_calcsubquery (so the columns are available to the window/adjacency computation) and the outer query. ASUM(score) OVER wprojection therefore appears at both levels, so theWINDOW w AS (...)definition must be threaded into the inner subquery too — an outer-only re-attach (the mechanism_PRESERVED_ROOT_ARGSuses for LIMIT/OFFSET/DISTINCT/QUALIFY) leaves the innerOVER wdangling. MERGE has an analogous inner/outer split.Expected outcome
A CLUSTER/MERGE query carrying a named
WINDOWclause referenced by a surviving projection transpiles to executable SQL that defines the window at whatever level(s) reference it, rather than raising. Until then the #181ValueErroris the correct interim behavior (loud, not silent).