@@ -198,18 +198,64 @@ export function queryHashKey(desc: QueryDescriptor): string {
198198 parts . push ( `g:${ [ ...desc . groupBy ] . sort ( ) . join ( "," ) } ` ) ;
199199 }
200200
201+ // Filter groups (OR)
202+ if ( desc . filterGroups && desc . filterGroups . length > 0 ) {
203+ for ( let gi = 0 ; gi < desc . filterGroups . length ; gi ++ ) {
204+ const grp = desc . filterGroups [ gi ] ;
205+ for ( const f of grp ) parts . push ( `fg${ gi } :${ f . column } :${ f . op } :${ stringifyValue ( f . value ) } ` ) ;
206+ }
207+ }
208+
209+ // Distinct
210+ if ( desc . distinct && desc . distinct . length > 0 ) {
211+ parts . push ( `d:${ [ ...desc . distinct ] . sort ( ) . join ( "," ) } ` ) ;
212+ }
213+
201214 // Vector search
202215 if ( desc . vectorSearch ) {
203216 const vs = desc . vectorSearch ;
204217 parts . push ( `v:${ vs . column } :${ vs . topK } :${ Array . from ( vs . queryVector ) . join ( "," ) } ` ) ;
205218 }
206219
220+ // Windows
221+ if ( desc . windows && desc . windows . length > 0 ) {
222+ for ( const w of desc . windows ) {
223+ let wp = `w:${ w . fn } :${ w . alias } :${ w . column ?? "" } ` ;
224+ if ( w . partitionBy ?. length ) wp += `:pb=${ w . partitionBy . join ( "," ) } ` ;
225+ if ( w . orderBy ?. length ) wp += `:ob=${ w . orderBy . map ( o => o . column + o . direction ) . join ( "," ) } ` ;
226+ if ( w . frame ) wp += `:fr=${ w . frame . type } :${ w . frame . start } :${ w . frame . end } ` ;
227+ parts . push ( wp ) ;
228+ }
229+ }
230+
231+ // Computed columns
232+ if ( desc . computedColumns && desc . computedColumns . length > 0 ) {
233+ for ( const cc of desc . computedColumns ) parts . push ( `cc:${ cc . alias } ` ) ;
234+ }
235+
236+ // Set operation
237+ if ( desc . setOperation ) {
238+ parts . push ( `so:${ desc . setOperation . mode } :${ queryHashKey ( desc . setOperation . right as QueryDescriptor ) } ` ) ;
239+ }
240+
241+ // Subquery IN
242+ if ( desc . subqueryIn ) {
243+ for ( const sq of desc . subqueryIn ) {
244+ parts . push ( `sq:${ sq . column } :${ [ ...sq . valueSet ] . sort ( ) . join ( "," ) } ` ) ;
245+ }
246+ }
247+
207248 // Join
208249 if ( desc . join ) {
209250 const j = desc . join ;
210251 parts . push ( `j:${ j . leftKey } :${ j . rightKey } :${ j . type ?? "inner" } :${ queryHashKey ( j . right as QueryDescriptor ) } ` ) ;
211252 }
212253
254+ // Version
255+ if ( desc . version !== undefined ) {
256+ parts . push ( `ver:${ desc . version } ` ) ;
257+ }
258+
213259 return parts . join ( "|" ) ;
214260}
215261
0 commit comments