add names/docs to some of the scalar expr constuctor fields, add partial support for explicit window frames
This commit is contained in:
parent
bfe07dce53
commit
e85ab8b831
5 changed files with 131 additions and 25 deletions
Language/SQL/SimpleSQL
|
@ -52,21 +52,34 @@
|
|||
> <+> commaSep (map scalarExpr es)
|
||||
> <+> orderBy od)
|
||||
|
||||
> scalarExpr (WindowApp f es pb od) =
|
||||
> scalarExpr (WindowApp f es pb od fr) =
|
||||
> name f <> parens (commaSep $ map scalarExpr es)
|
||||
> <+> text "over"
|
||||
> <+> parens ((case pb of
|
||||
> [] -> empty
|
||||
> _ -> text "partition by"
|
||||
> <+> nest 13 (commaSep $ map scalarExpr pb))
|
||||
> <+> orderBy od)
|
||||
> <+> orderBy od
|
||||
> <+> maybe empty frd fr)
|
||||
> where
|
||||
> frd (FrameFrom rs fp) = rsd rs <+> fpd fp
|
||||
> frd (FrameBetween rs fps fpe) =
|
||||
> rsd rs <+> text "between" <+> fpd fps
|
||||
> <+> text "and" <+> fpd fpe
|
||||
> rsd rs = case rs of
|
||||
> FrameRows -> text "rows"
|
||||
> FrameRange -> text "range"
|
||||
> fpd UnboundedPreceding = text "unbounded preceding"
|
||||
> fpd UnboundedFollowing = text "unbounded following"
|
||||
> fpd Current = text "current row"
|
||||
> fpd (Preceding e) = scalarExpr e <+> text "preceding"
|
||||
> fpd (Following e) = scalarExpr e <+> text "following"
|
||||
|
||||
> scalarExpr (SpecialOp nm [a,b,c]) | nm `elem` [Name "between"
|
||||
> ,Name "not between"] =
|
||||
> sep [scalarExpr a
|
||||
> ,name nm <+> scalarExpr b
|
||||
> ,nest (length (unname nm) + 1)
|
||||
> $ text "and" <+> scalarExpr c]
|
||||
> ,nest (length (unname nm) + 1) $ text "and" <+> scalarExpr c]
|
||||
|
||||
> scalarExpr (SpecialOp (Name "extract") [a,n]) =
|
||||
> text "extract" <> parens (scalarExpr a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue