on dev help sign in
return null types from aggregates
d0eec89Eitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+30−30
@@ -1469,22 +1469,22 @@ class Aggregate expr1 expr2 aggr
1469 sum_
1469 sum_
1470 :: ty `In` PGNum
1470 :: ty `In` PGNum
1471 => expr1 (nullity ty)
1471 => expr1 (nullity ty)
1472− -> aggr (nullity ty)
1472+ -> aggr ('Null ty)
1473
1473
1474 -- | input values, including nulls, concatenated into an array
1474 -- | input values, including nulls, concatenated into an array
1475 arrayAgg
1475 arrayAgg
1476 :: expr1 ty
1476 :: expr1 ty
1477− -> aggr ('NotNull ('PGvararray ty))
1477+ -> aggr ('Null ('PGvararray ty))
1478
1478
1479 -- | aggregates values as a JSON array
1479 -- | aggregates values as a JSON array
1480 jsonAgg
1480 jsonAgg
1481 :: expr1 ty
1481 :: expr1 ty
1482− -> aggr ('NotNull 'PGjson)
1482+ -> aggr ('Null 'PGjson)
1483
1483
1484 -- | aggregates values as a JSON array
1484 -- | aggregates values as a JSON array
1485 jsonbAgg
1485 jsonbAgg
1486 :: expr1 ty
1486 :: expr1 ty
1487− -> aggr ('NotNull 'PGjsonb)
1487+ -> aggr ('Null 'PGjsonb)
1488
1488
1489 -- | >>> :{
1489 -- | >>> :{
1490 -- let
1490 -- let
@@ -1497,7 +1497,7 @@ class Aggregate expr1 expr2 aggr
1497 :: int `In` PGIntegral
1497 :: int `In` PGIntegral
1498 => expr1 (nullity int)
1498 => expr1 (nullity int)
1499 -- ^ what to aggregate
1499 -- ^ what to aggregate
1500− -> aggr (nullity int)
1500+ -> aggr ('Null int)
1501
1501
1502 -- | >>> :{
1502 -- | >>> :{
1503 -- let
1503 -- let
@@ -1510,7 +1510,7 @@ class Aggregate expr1 expr2 aggr
1510 :: int `In` PGIntegral
1510 :: int `In` PGIntegral
1511 => expr1 (nullity int)
1511 => expr1 (nullity int)
1512 -- ^ what to aggregate
1512 -- ^ what to aggregate
1513− -> aggr (nullity int)
1513+ -> aggr ('Null int)
1514
1514
1515 -- | >>> :{
1515 -- | >>> :{
1516 -- let
1516 -- let
@@ -1522,7 +1522,7 @@ class Aggregate expr1 expr2 aggr
1522 boolAnd
1522 boolAnd
1523 :: expr1 (nullity 'PGbool)
1523 :: expr1 (nullity 'PGbool)
1524 -- ^ what to aggregate
1524 -- ^ what to aggregate
1525− -> aggr (nullity 'PGbool)
1525+ -> aggr ('Null 'PGbool)
1526
1526
1527 -- | >>> :{
1527 -- | >>> :{
1528 -- let
1528 -- let
@@ -1534,7 +1534,7 @@ class Aggregate expr1 expr2 aggr
1534 boolOr
1534 boolOr
1535 :: expr1(nullity 'PGbool)
1535 :: expr1(nullity 'PGbool)
1536 -- ^ what to aggregate
1536 -- ^ what to aggregate
1537− -> aggr (nullity 'PGbool)
1537+ -> aggr ('Null 'PGbool)
1538
1538
1539 -- | synonym for `boolAnd`
1539 -- | synonym for `boolAnd`
1540 --
1540 --
@@ -1548,25 +1548,25 @@ class Aggregate expr1 expr2 aggr
1548 every
1548 every
1549 :: expr1 (nullity 'PGbool)
1549 :: expr1 (nullity 'PGbool)
1550 -- ^ what to aggregate
1550 -- ^ what to aggregate
1551− -> aggr (nullity 'PGbool)
1551+ -> aggr ('Null 'PGbool)
1552
1552
1553 -- | maximum value of expression across all input values
1553 -- | maximum value of expression across all input values
1554 max_
1554 max_
1555 :: expr1 (nullity ty)
1555 :: expr1 (nullity ty)
1556 -- ^ what to maximize
1556 -- ^ what to maximize
1557− -> aggr (nullity ty)
1557+ -> aggr ('Null ty)
1558
1558
1559 -- | minimum value of expression across all input values
1559 -- | minimum value of expression across all input values
1560 min_
1560 min_
1561 :: expr1 (nullity ty)
1561 :: expr1 (nullity ty)
1562 -- ^ what to minimize
1562 -- ^ what to minimize
1563− -> aggr (nullity ty)
1563+ -> aggr ('Null ty)
1564
1564
1565 -- | average aggregation
1565 -- | average aggregation
1566 avg
1566 avg
1567 :: expr1 (nullity ty)
1567 :: expr1 (nullity ty)
1568 -- ^ what to average
1568 -- ^ what to average
1569− -> aggr (nullity (PGAvg ty))
1569+ -> aggr ('Null (PGAvg ty))
1570
1570
1571 {- | correlation coefficient
1571 {- | correlation coefficient
1572 >>> :{
1572 >>> :{
@@ -1579,7 +1579,7 @@ class Aggregate expr1 expr2 aggr
1579 -}
1579 -}
1580 corr
1580 corr
1581 :: expr2 (nullity 'PGfloat8)
1581 :: expr2 (nullity 'PGfloat8)
1582− -> aggr (nullity 'PGfloat8)
1582+ -> aggr ('Null 'PGfloat8)
1583
1583
1584 {- | population covariance
1584 {- | population covariance
1585 >>> :{
1585 >>> :{
@@ -1592,7 +1592,7 @@ class Aggregate expr1 expr2 aggr
1592 -}
1592 -}
1593 covarPop
1593 covarPop
1594 :: expr2 (nullity 'PGfloat8)
1594 :: expr2 (nullity 'PGfloat8)
1595− -> aggr (nullity 'PGfloat8)
1595+ -> aggr ('Null 'PGfloat8)
1596
1596
1597 {- | sample covariance
1597 {- | sample covariance
1598 >>> :{
1598 >>> :{
@@ -1605,7 +1605,7 @@ class Aggregate expr1 expr2 aggr
1605 -}
1605 -}
1606 covarSamp
1606 covarSamp
1607 :: expr2 (nullity 'PGfloat8)
1607 :: expr2 (nullity 'PGfloat8)
1608− -> aggr (nullity 'PGfloat8)
1608+ -> aggr ('Null 'PGfloat8)
1609
1609
1610 {- | average of the independent variable (sum(X)/N)
1610 {- | average of the independent variable (sum(X)/N)
1611 >>> :{
1611 >>> :{
@@ -1618,7 +1618,7 @@ class Aggregate expr1 expr2 aggr
1618 -}
1618 -}
1619 regrAvgX
1619 regrAvgX
1620 :: expr2 (nullity 'PGfloat8)
1620 :: expr2 (nullity 'PGfloat8)
1621− -> aggr (nullity 'PGfloat8)
1621+ -> aggr ('Null 'PGfloat8)
1622
1622
1623 {- | average of the dependent variable (sum(Y)/N)
1623 {- | average of the dependent variable (sum(Y)/N)
1624 >>> :{
1624 >>> :{
@@ -1631,7 +1631,7 @@ class Aggregate expr1 expr2 aggr
1631 -}
1631 -}
1632 regrAvgY
1632 regrAvgY
1633 :: expr2 (nullity 'PGfloat8)
1633 :: expr2 (nullity 'PGfloat8)
1634− -> aggr (nullity 'PGfloat8)
1634+ -> aggr ('Null 'PGfloat8)
1635
1635
1636 {- | number of input rows in which both expressions are nonnull
1636 {- | number of input rows in which both expressions are nonnull
1637 >>> :{
1637 >>> :{
@@ -1644,7 +1644,7 @@ class Aggregate expr1 expr2 aggr
1644 -}
1644 -}
1645 regrCount
1645 regrCount
1646 :: expr2 (nullity 'PGfloat8)
1646 :: expr2 (nullity 'PGfloat8)
1647− -> aggr (nullity 'PGint8)
1647+ -> aggr ('Null 'PGint8)
1648
1648
1649 {- | y-intercept of the least-squares-fit linear equation determined by the (X, Y) pairs
1649 {- | y-intercept of the least-squares-fit linear equation determined by the (X, Y) pairs
1650 >>> :{
1650 >>> :{
@@ -1657,68 +1657,68 @@ class Aggregate expr1 expr2 aggr
1657 -}
1657 -}
1658 regrIntercept
1658 regrIntercept
1659 :: expr2 (nullity 'PGfloat8)
1659 :: expr2 (nullity 'PGfloat8)
1660− -> aggr (nullity 'PGfloat8)
1660+ -> aggr ('Null 'PGfloat8)
1661
1661
1662 -- | @regr_r2(Y, X)@, square of the correlation coefficient
1662 -- | @regr_r2(Y, X)@, square of the correlation coefficient
1663 regrR2
1663 regrR2
1664 :: expr2 (nullity 'PGfloat8)
1664 :: expr2 (nullity 'PGfloat8)
1665− -> aggr (nullity 'PGfloat8)
1665+ -> aggr ('Null 'PGfloat8)
1666
1666
1667 -- | @regr_slope(Y, X)@, slope of the least-squares-fit linear equation
1667 -- | @regr_slope(Y, X)@, slope of the least-squares-fit linear equation
1668 -- determined by the (X, Y) pairs
1668 -- determined by the (X, Y) pairs
1669 regrSlope
1669 regrSlope
1670 :: expr2 (nullity 'PGfloat8)
1670 :: expr2 (nullity 'PGfloat8)
1671− -> aggr (nullity 'PGfloat8)
1671+ -> aggr ('Null 'PGfloat8)
1672
1672
1673 -- | @regr_sxx(Y, X)@, sum(X^2) - sum(X)^2/N
1673 -- | @regr_sxx(Y, X)@, sum(X^2) - sum(X)^2/N
1674 -- (“sum of squares” of the independent variable)
1674 -- (“sum of squares” of the independent variable)
1675 regrSxx
1675 regrSxx
1676 :: expr2 (nullity 'PGfloat8)
1676 :: expr2 (nullity 'PGfloat8)
1677− -> aggr (nullity 'PGfloat8)
1677+ -> aggr ('Null 'PGfloat8)
1678
1678
1679 -- | @regr_sxy(Y, X)@, sum(X*Y) - sum(X) * sum(Y)/N
1679 -- | @regr_sxy(Y, X)@, sum(X*Y) - sum(X) * sum(Y)/N
1680 -- (“sum of products” of independent times dependent variable)
1680 -- (“sum of products” of independent times dependent variable)
1681 regrSxy
1681 regrSxy
1682 :: expr2 (nullity 'PGfloat8)
1682 :: expr2 (nullity 'PGfloat8)
1683− -> aggr (nullity 'PGfloat8)
1683+ -> aggr ('Null 'PGfloat8)
1684
1684
1685 -- | @regr_syy(Y, X)@, sum(Y^2) - sum(Y)^2/N
1685 -- | @regr_syy(Y, X)@, sum(Y^2) - sum(Y)^2/N
1686 -- (“sum of squares” of the dependent variable)
1686 -- (“sum of squares” of the dependent variable)
1687 regrSyy
1687 regrSyy
1688 :: expr2 (nullity 'PGfloat8)
1688 :: expr2 (nullity 'PGfloat8)
1689− -> aggr (nullity 'PGfloat8)
1689+ -> aggr ('Null 'PGfloat8)
1690
1690
1691 -- | historical alias for `stddevSamp`
1691 -- | historical alias for `stddevSamp`
1692 stddev
1692 stddev
1693 :: expr1 (nullity ty)
1693 :: expr1 (nullity ty)
1694− -> aggr (nullity (PGAvg ty))
1694+ -> aggr ('Null (PGAvg ty))
1695
1695
1696 -- | population standard deviation of the input values
1696 -- | population standard deviation of the input values
1697 stddevPop
1697 stddevPop
1698 :: expr1 (nullity ty)
1698 :: expr1 (nullity ty)
1699− -> aggr (nullity (PGAvg ty))
1699+ -> aggr ('Null (PGAvg ty))
1700
1700
1701 -- | sample standard deviation of the input values
1701 -- | sample standard deviation of the input values
1702 stddevSamp
1702 stddevSamp
1703 :: expr1 (nullity ty)
1703 :: expr1 (nullity ty)
1704− -> aggr (nullity (PGAvg ty))
1704+ -> aggr ('Null (PGAvg ty))
1705
1705
1706 -- | historical alias for `varSamp`
1706 -- | historical alias for `varSamp`
1707 variance
1707 variance
1708 :: expr1 (nullity ty)
1708 :: expr1 (nullity ty)
1709− -> aggr (nullity (PGAvg ty))
1709+ -> aggr ('Null (PGAvg ty))
1710
1710
1711 -- | population variance of the input values
1711 -- | population variance of the input values
1712 -- (square of the population standard deviation)
1712 -- (square of the population standard deviation)
1713 varPop
1713 varPop
1714 :: expr1 (nullity ty)
1714 :: expr1 (nullity ty)
1715− -> aggr (nullity (PGAvg ty))
1715+ -> aggr ('Null (PGAvg ty))
1716
1716
1717 -- | sample variance of the input values
1717 -- | sample variance of the input values
1718 -- (square of the sample standard deviation)
1718 -- (square of the sample standard deviation)
1719 varSamp
1719 varSamp
1720 :: expr1 (nullity ty)
1720 :: expr1 (nullity ty)
1721− -> aggr (nullity (PGAvg ty))
1721+ -> aggr ('Null (PGAvg ty))
1722
1722
1723{- |
1723{- |
1724`Distinction`s are used for the input of `Aggregate` `Expression`s.
1724`Distinction`s are used for the input of `Aggregate` `Expression`s.