@@ -164,7 +164,15 @@ yy.Select.prototype.compileGroup = function (query) {
164164 } else if ( col . aggregatorid === 'REDUCE' ) {
165165 query . aggrKeys . push ( col ) ;
166166 const extraParams = getGroupConcatParams ( col ) ;
167- return `'${ colas } ':alasql.aggr['${ col . funcid } '](${ colexp } ,undefined,1${ extraParams } ),` ;
167+ // Support multiple arguments for user-defined aggregates
168+ if ( col . args && col . args . length > 1 ) {
169+ // Multiple arguments - pass all of them
170+ let argExpressions = col . args . map ( arg => arg . toJS ( 'p' , tableid , defcols ) ) . join ( ',' ) ;
171+ return `'${ colas } ':alasql.aggr['${ col . funcid } '](${ argExpressions } ,undefined,1${ extraParams } ),` ;
172+ } else {
173+ // Single argument - backward compatibility
174+ return `'${ colas } ':alasql.aggr['${ col . funcid } '](${ colexp } ,undefined,1${ extraParams } ),` ;
175+ }
168176 }
169177 return '' ;
170178 }
@@ -435,11 +443,20 @@ yy.Select.prototype.compileGroup = function (query) {
435443 ${ post } ` ;
436444 } else if ( col . aggregatorid === 'REDUCE' ) {
437445 const extraParams = getGroupConcatParams ( col ) ;
438- return `${ pre }
439- g['${ colas } '] = alasql.aggr.${ col . funcid } (${ colexp } ,g['${ colas } '],2${ extraParams } );
440- ${ post } ` ;
446+ // Support multiple arguments for user-defined aggregates
447+ if ( col . args && col . args . length > 1 ) {
448+ // Multiple arguments - pass all of them
449+ let argExpressions = col . args . map ( arg => arg . toJS ( 'p' , tableid , defcols ) ) . join ( ',' ) ;
450+ return `${ pre }
451+ g['${ colas } '] = alasql.aggr.${ col . funcid } (${ argExpressions } ,g['${ colas } '],2${ extraParams } );
452+ ${ post } ` ;
453+ } else {
454+ // Single argument - backward compatibility
455+ return `${ pre }
456+ g['${ colas } '] = alasql.aggr.${ col . funcid } (${ colexp } ,g['${ colas } '],2${ extraParams } );
457+ ${ post } ` ;
458+ }
441459 }
442-
443460 return '' ;
444461 }
445462
0 commit comments