Description
Implement the generic NEAREST expander, which produces the LATERAL + SELECT AST, with a capability-driven fallback to a window-function form for targets whose supports_lateral capability is false. Materialize the row passthrough and the synthesized distance column as AST so NEAREST's output handling no longer lives in the string emitter. Flip GIQL_EXPAND on GIQLNearest and delete giqlnearest_sql.
Motivation
NEAREST is the first operator whose expansion is genuinely capability-conditional, exercising the capability model that lets one operator serve engines with differing feature support.
Expected Outcome
NEAREST transpiles through the registry; lateral-capable targets receive the LATERAL form and others the window-function fallback; results are identical across DuckDB and DataFusion and unchanged; giqlnearest_sql is removed.
Description
Implement the generic NEAREST expander, which produces the
LATERAL+SELECTAST, with a capability-driven fallback to a window-function form for targets whosesupports_lateralcapability is false. Materialize the row passthrough and the synthesizeddistancecolumn as AST so NEAREST's output handling no longer lives in the string emitter. FlipGIQL_EXPANDonGIQLNearestand deletegiqlnearest_sql.Motivation
NEAREST is the first operator whose expansion is genuinely capability-conditional, exercising the capability model that lets one operator serve engines with differing feature support.
Expected Outcome
NEAREST transpiles through the registry; lateral-capable targets receive the LATERAL form and others the window-function fallback; results are identical across DuckDB and DataFusion and unchanged;
giqlnearest_sqlis removed.