Skip to content

Commit 5b9e1aa

Browse files
committed
fix: use astformat.String for multi-arg functions to preserve OVER clause
The inferColNameFromExpr function was manually constructing the decorated column for functions with 0 or 2+ arguments using fmt.Sprintf, which did not include the OVER clause for window functions like ROW_NUMBER(), RANK(), etc. Changed to use astformat.String(expr, formatter) which properly calls FuncExpr.Format() and includes the OVER clause.
1 parent 1615712 commit 5b9e1aa

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

internal/stackql/parserutil/parser_util.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,8 @@ func inferColNameFromExpr(
676676
exprsDecorated = append(exprsDecorated, rv.DecoratedColumn)
677677
}
678678
}
679-
decoratedColumn := fmt.Sprintf("%s(%s)", funcNameLowered, strings.Join(exprsDecorated, ", "))
679+
// Use astformat.String to include OVER clause for window functions
680+
decoratedColumn := astformat.String(expr, formatter)
680681
if retVal.Name != constants.SQLFuncJSONExtractPostgres {
681682
retVal.DecoratedColumn = getDecoratedColRendition(decoratedColumn, alias)
682683
}

0 commit comments

Comments
 (0)