Merge pull request #397 from BranislavLazic/add-pg-generate-series

Add Postgres GENERATE_SERIES function
This commit is contained in:
go-jet 2024-10-28 12:00:37 +01:00 committed by GitHub
commit bee431f870
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 0 deletions

View file

@ -344,6 +344,15 @@ func DATE_TRUNC(field unit, source Expression, timezone ...string) TimestampExpr
return jet.NewTimestampFunc("DATE_TRUNC", jet.FixedLiteral(unitToString(field)), source)
}
// GENERATE_SERIES generates a series of values from start to stop, with a step size of step.
func GENERATE_SERIES(start Expression, stop Expression, step ...Expression) Expression {
if len(step) > 0 {
return jet.NewFunc("GENERATE_SERIES", []Expression{start, stop, step[0]}, nil)
}
return jet.NewFunc("GENERATE_SERIES", []Expression{start, stop}, nil)
}
// --------------- Conditional Expressions Functions -------------//
// COALESCE function returns the first of its arguments that is not null.