on dev help sign in
agg stuff
commitbf722d17d13d4c67f9cf09e32b477a6e620e91bb authorEitan Chatav <eitan@Eitans-MacBook-Pro.local> dateFri 1 Mar 2019, 13:22 (8 years ago) parentd0eec89
1 file changed+58−41
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+58−41
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+58−41
@@ -1461,7 +1461,7 @@ class Aggregate expr1 expr2 aggr
14611461
14621462 -- | >>> :{
14631463 -- let
1464− -- expression :: Expression '[] ('Grouped bys) commons schemas params '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('Null 'PGnumeric)
1464+ -- expression :: Expression '[] ('Grouped bys) commons schemas params '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('NotNull 'PGnumeric)
14651465 -- expression = sum_ (Distinct #col)
14661466 -- in printSQL expression
14671467 -- :}
@@ -1469,7 +1469,7 @@ class Aggregate expr1 expr2 aggr
14691469 sum_
14701470 :: ty `In` PGNum
14711471 => expr1 (nullity ty)
1472− -> aggr ('Null ty)
1472+ -> aggr ('NotNull ty)
14731473
14741474 -- | input values, including nulls, concatenated into an array
14751475 arrayAgg
@@ -1486,71 +1486,88 @@ class Aggregate expr1 expr2 aggr
14861486 :: expr1 ty
14871487 -> aggr ('Null 'PGjsonb)
14881488
1489− -- | >>> :{
1490− -- let
1491− -- expression :: Expression '[] ('Grouped bys) commons schemas params '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1492− -- expression = bitAnd (Distinct #col)
1493− -- in printSQL expression
1494− -- :}
1495− -- bit_and(DISTINCT "col")
1489+ {- |
1490+ the bitwise AND of all non-null input values, or null if none
1491+ >>> :{
1492+ let
1493+ expression :: Expression '[] ('Grouped bys) commons schemas params '[tab ::: '["col" ::: nullity 'PGint4]] ('Null 'PGint4)
1494+ expression = bitAnd (Distinct #col)
1495+ in printSQL expression
1496+ :}
1497+ bit_and(DISTINCT "col")
1498+ -}
14961499 bitAnd
14971500 :: int `In` PGIntegral
14981501 => expr1 (nullity int)
14991502 -- ^ what to aggregate
15001503 -> aggr ('Null int)
15011504
1502− -- | >>> :{
1503− -- let
1504− -- expression :: Expression '[] ('Grouped bys) commons schemas params '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1505− -- expression = bitOr (All #col)
1506− -- in printSQL expression
1507− -- :}
1508− -- bit_or(ALL "col")
1505+ {- |
1506+ the bitwise OR of all non-null input values, or null if none
1507+
1508+ >>> :{
1509+ let
1510+ expression :: Expression '[] ('Grouped bys) commons schemas params '[tab ::: '["col" ::: nullity 'PGint4]] ('Null 'PGint4)
1511+ expression = bitOr (All #col)
1512+ in printSQL expression
1513+ :}
1514+ bit_or(ALL "col")
1515+ -}
15091516 bitOr
15101517 :: int `In` PGIntegral
15111518 => expr1 (nullity int)
15121519 -- ^ what to aggregate
15131520 -> aggr ('Null int)
15141521
1515− -- | >>> :{
1516− -- let
1517− -- winFun :: WindowFunction '[] 'Ungrouped commons schemas params '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1518− -- winFun = boolAnd #col
1519− -- in printSQL winFun
1520− -- :}
1521− -- bool_and("col")
1522+ {- |
1523+ true if all input values are true, otherwise false
1524+
1525+ >>> :{
1526+ let
1527+ winFun :: WindowFunction '[] 'Ungrouped commons schemas params '[tab ::: '["col" ::: nullity 'PGbool]] ('Null 'PGbool)
1528+ winFun = boolAnd #col
1529+ in printSQL winFun
1530+ :}
1531+ bool_and("col")
1532+ -}
15221533 boolAnd
15231534 :: expr1 (nullity 'PGbool)
15241535 -- ^ what to aggregate
15251536 -> aggr ('Null 'PGbool)
15261537
1527− -- | >>> :{
1528− -- let
1529− -- expression :: Expression '[] ('Grouped bys) commons schemas params '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1530− -- expression = boolOr (All #col)
1531− -- in printSQL expression
1532− -- :}
1533− -- bool_or(ALL "col")
1538+ {- |
1539+ true if at least one input value is true, otherwise false
1540+
1541+ >>> :{
1542+ let
1543+ expression :: Expression '[] ('Grouped bys) commons schemas params '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1544+ expression = boolOr (All #col)
1545+ in printSQL expression
1546+ :}
1547+ bool_or(ALL "col")
1548+ -}
15341549 boolOr
15351550 :: expr1(nullity 'PGbool)
15361551 -- ^ what to aggregate
15371552 -> aggr ('Null 'PGbool)
15381553
1539− -- | synonym for `boolAnd`
1540− --
1541− -- >>> :{
1542− -- let
1543− -- expression :: Expression '[] ('Grouped bys) commons schemas params '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1544− -- expression = every (Distinct #col)
1545− -- in printSQL expression
1546− -- :}
1547− -- every(DISTINCT "col")
1554+ {- |
1555+ equivalent to `boolAnd`
1556+
1557+ >>> :{
1558+ let
1559+ expression :: Expression '[] ('Grouped bys) commons schemas params '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1560+ expression = every (Distinct #col)
1561+ in printSQL expression
1562+ :}
1563+ every(DISTINCT "col")
1564+ -}
15481565 every
15491566 :: expr1 (nullity 'PGbool)
15501567 -- ^ what to aggregate
15511568 -> aggr ('Null 'PGbool)
15521569
1553− -- | maximum value of expression across all input values
1570+ {- |maximum value of expression across all input values-}
15541571 max_
15551572 :: expr1 (nullity ty)
15561573 -- ^ what to maximize
@@ -1562,7 +1579,7 @@ class Aggregate expr1 expr2 aggr
15621579 -- ^ what to minimize
15631580 -> aggr ('Null ty)
15641581
1565− -- | average aggregation
1582+ -- | the average (arithmetic mean) of all input values
15661583 avg
15671584 :: expr1 (nullity ty)
15681585 -- ^ what to average