module Database.Beam.Query.Aggregate
(
aggregate_
, filterWhere_, filterWhere_'
, QGroupable(..)
, sum_, avg_, min_, max_, count_, countAll_
, rank_, cumeDist_, percentRank_, denseRank_
, rowNumber_
, every_, any_, some_
, sumOver_, avgOver_, minOver_, maxOver_, countOver_
, everyOver_, anyOver_, someOver_
, distinctInGroup_, allInGroup_, allInGroupExplicitly_
) where
import Database.Beam.Query.Internal
import Database.Beam.Query.Operator
import Database.Beam.Query.Ord
import Database.Beam.Backend.SQL
import Database.Beam.Schema.Tables
import Control.Applicative
import Control.Monad.Writer
import Control.Monad.Free
import Data.Typeable
type Aggregable be a =
ProjectibleWithPredicate AggregateContext be (WithExprContext (BeamSqlBackendExpressionSyntax' be)) a
aggregate_ :: forall be a r db s.
( BeamSqlBackend be
, Aggregable be a, Projectible be r, Projectible be a
, ContextRewritable a
, ThreadRewritable (QNested s) (WithRewrittenContext a QValueContext)
)
=> (r -> a)
-> Q be db (QNested s) r
-> Q be db s (WithRewrittenThread (QNested s) s (WithRewrittenContext a QValueContext))
aggregate_ :: (r -> a)
-> Q be db (QNested s) r
-> Q be
db
s
(WithRewrittenThread
(QNested s) s (WithRewrittenContext a QValueContext))
aggregate_ r -> a
mkAggregation (Q QM be db (QNested s) r
aggregating) =
QM
be
db
s
(WithRewrittenThread
(QNested s) s (WithRewrittenContext a QValueContext))
-> Q be
db
s
(WithRewrittenThread
(QNested s) s (WithRewrittenContext a QValueContext))
forall be (db :: (* -> *) -> *) s a. QM be db s a -> Q be db s a
Q (QF
be
db
s
(WithRewrittenThread
(QNested s) s (WithRewrittenContext a QValueContext))
-> QM
be
db
s
(WithRewrittenThread
(QNested s) s (WithRewrittenContext a QValueContext))
forall (f :: * -> *) (m :: * -> *) a.
(Functor f, MonadFree f m) =>
f a -> m a
liftF ((r -> TablePrefix -> (Maybe (BeamSqlBackendGroupingSyntax be), a))
-> QM be db (QNested s) r
-> (a
-> WithRewrittenThread
(QNested s) s (WithRewrittenContext a QValueContext))
-> QF
be
db
s
(WithRewrittenThread
(QNested s) s (WithRewrittenContext a QValueContext))
forall be grouping a (db :: (* -> *) -> *) s next.
(Projectible be grouping, Projectible be a) =>
(a
-> TablePrefix
-> (Maybe (BeamSqlBackendGroupingSyntax be), grouping))
-> QM be db (QNested s) a -> (grouping -> next) -> QF be db s next
QAggregate r -> TablePrefix -> (Maybe (BeamSqlBackendGroupingSyntax be), a)
mkAggregation' QM be db (QNested s) r
aggregating (Proxy s
-> WithRewrittenContext a QValueContext
-> WithRewrittenThread
(QNested s) s (WithRewrittenContext a QValueContext)
forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread (Proxy s
forall k (t :: k). Proxy t
Proxy @s) (WithRewrittenContext a QValueContext
-> WithRewrittenThread
(QNested s) s (WithRewrittenContext a QValueContext))
-> (a -> WithRewrittenContext a QValueContext)
-> a
-> WithRewrittenThread
(QNested s) s (WithRewrittenContext a QValueContext)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy QValueContext -> a -> WithRewrittenContext a QValueContext
forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext (Proxy QValueContext
forall k (t :: k). Proxy t
Proxy @QValueContext))))
where
mkAggregation' :: r -> TablePrefix -> (Maybe (BeamSqlBackendGroupingSyntax be), a)
mkAggregation' r
x TablePrefix
tblPfx =
let agg :: a
agg = r -> a
mkAggregation r
x
doProject :: AggregateContext c
=> Proxy c -> Proxy be
-> WithExprContext (BeamSqlBackendExpressionSyntax' be)
-> Writer [WithExprContext (BeamSqlBackendExpressionSyntax' be)]
(WithExprContext (BeamSqlBackendExpressionSyntax' be))
doProject :: Proxy c
-> Proxy be
-> WithExprContext (BeamSqlBackendExpressionSyntax' be)
-> Writer
[WithExprContext (BeamSqlBackendExpressionSyntax' be)]
(WithExprContext (BeamSqlBackendExpressionSyntax' be))
doProject Proxy c
p Proxy be
_ WithExprContext (BeamSqlBackendExpressionSyntax' be)
expr =
case Proxy c -> Maybe (Proxy QGroupingContext)
forall a b. (Typeable a, Typeable b) => a -> Maybe b
cast Proxy c
p of
Just (Proxy QGroupingContext
Proxy :: Proxy QGroupingContext) ->
[WithExprContext (BeamSqlBackendExpressionSyntax' be)]
-> WriterT
[WithExprContext (BeamSqlBackendExpressionSyntax' be)] Identity ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell [ WithExprContext (BeamSqlBackendExpressionSyntax' be)
expr ] WriterT
[WithExprContext (BeamSqlBackendExpressionSyntax' be)] Identity ()
-> Writer
[WithExprContext (BeamSqlBackendExpressionSyntax' be)]
(WithExprContext (BeamSqlBackendExpressionSyntax' be))
-> Writer
[WithExprContext (BeamSqlBackendExpressionSyntax' be)]
(WithExprContext (BeamSqlBackendExpressionSyntax' be))
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> WithExprContext (BeamSqlBackendExpressionSyntax' be)
-> Writer
[WithExprContext (BeamSqlBackendExpressionSyntax' be)]
(WithExprContext (BeamSqlBackendExpressionSyntax' be))
forall (f :: * -> *) a. Applicative f => a -> f a
pure WithExprContext (BeamSqlBackendExpressionSyntax' be)
expr
Maybe (Proxy QGroupingContext)
Nothing ->
case Proxy c -> Maybe (Proxy QAggregateContext)
forall a b. (Typeable a, Typeable b) => a -> Maybe b
cast Proxy c
p of
Just (Proxy QAggregateContext
Proxy :: Proxy QAggregateContext) ->
WithExprContext (BeamSqlBackendExpressionSyntax' be)
-> Writer
[WithExprContext (BeamSqlBackendExpressionSyntax' be)]
(WithExprContext (BeamSqlBackendExpressionSyntax' be))
forall (f :: * -> *) a. Applicative f => a -> f a
pure WithExprContext (BeamSqlBackendExpressionSyntax' be)
expr
Maybe (Proxy QAggregateContext)
Nothing -> [Char]
-> Writer
[WithExprContext (BeamSqlBackendExpressionSyntax' be)]
(WithExprContext (BeamSqlBackendExpressionSyntax' be))
forall a. HasCallStack => [Char] -> a
error [Char]
"aggregate_: impossible"
groupingExprs :: [TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))]
groupingExprs =
(WithExprContext (BeamSqlBackendExpressionSyntax' be)
-> TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)))
-> [WithExprContext (BeamSqlBackendExpressionSyntax' be)]
-> [TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((BeamSqlBackendExpressionSyntax' be
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)))
-> WithExprContext (BeamSqlBackendExpressionSyntax' be)
-> TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap BeamSqlBackendExpressionSyntax' be
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
forall be.
BeamSqlBackendExpressionSyntax' be
-> BeamSqlBackendExpressionSyntax be
fromBeamSqlBackendExpressionSyntax) ([WithExprContext (BeamSqlBackendExpressionSyntax' be)]
-> [TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))])
-> [WithExprContext (BeamSqlBackendExpressionSyntax' be)]
-> [TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))]
forall a b. (a -> b) -> a -> b
$
Writer [WithExprContext (BeamSqlBackendExpressionSyntax' be)] a
-> [WithExprContext (BeamSqlBackendExpressionSyntax' be)]
forall w a. Writer w a -> w
execWriter (Proxy AggregateContext
-> Proxy (be, WithExprContext (BeamSqlBackendExpressionSyntax' be))
-> (forall context.
AggregateContext context =>
Proxy context
-> Proxy be
-> WithExprContext (BeamSqlBackendExpressionSyntax' be)
-> Writer
[WithExprContext (BeamSqlBackendExpressionSyntax' be)]
(WithExprContext (BeamSqlBackendExpressionSyntax' be)))
-> a
-> Writer [WithExprContext (BeamSqlBackendExpressionSyntax' be)] a
forall (contextPredicate :: * -> Constraint) be res a
(m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' (Proxy AggregateContext
forall k (t :: k). Proxy t
Proxy @AggregateContext) (Proxy (be, WithExprContext (BeamSqlBackendExpressionSyntax' be))
forall k (t :: k). Proxy t
Proxy @(be, WithExprContext (BeamSqlBackendExpressionSyntax' be))) forall context.
AggregateContext context =>
Proxy context
-> Proxy be
-> WithExprContext (BeamSqlBackendExpressionSyntax' be)
-> Writer
[WithExprContext (BeamSqlBackendExpressionSyntax' be)]
(WithExprContext (BeamSqlBackendExpressionSyntax' be))
doProject a
agg)
in case [TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))]
groupingExprs of
[] -> (Maybe (BeamSqlBackendGroupingSyntax be)
forall a. Maybe a
Nothing, a
agg)
[TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))]
_ -> (BeamSqlBackendGroupingSyntax be
-> Maybe (BeamSqlBackendGroupingSyntax be)
forall a. a -> Maybe a
Just ([Sql92GroupingExpressionSyntax (BeamSqlBackendGroupingSyntax be)]
-> BeamSqlBackendGroupingSyntax be
forall grouping.
IsSql92GroupingSyntax grouping =>
[Sql92GroupingExpressionSyntax grouping] -> grouping
groupByExpressions ([TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))]
-> TablePrefix
-> [Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA [TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))]
groupingExprs TablePrefix
tblPfx)), a
agg)
class QGroupable expr grouped | expr -> grouped, grouped -> expr where
group_ :: expr -> grouped
instance QGroupable (QExpr be s a) (QGroupExpr be s a) where
group_ :: QExpr be s a -> QGroupExpr be s a
group_ (QExpr TablePrefix -> BeamSqlBackendExpressionSyntax be
a) = (TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGroupExpr be s a
forall context be s t.
(TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr TablePrefix -> BeamSqlBackendExpressionSyntax be
a
instance Beamable tbl =>
QGroupable (tbl (QExpr be s)) (tbl (QGroupExpr be s)) where
group_ :: tbl (QExpr be s) -> tbl (QGroupExpr be s)
group_ = (forall a.
Columnar' (QExpr be s) a -> Columnar' (QGroupExpr be s) a)
-> tbl (QExpr be s) -> tbl (QGroupExpr be s)
forall (table :: (* -> *) -> *) (f :: * -> *) (g :: * -> *).
Beamable table =>
(forall a. Columnar' f a -> Columnar' g a) -> table f -> table g
changeBeamRep (\(Columnar' (QExpr x)) -> Columnar (QGroupExpr be s) a -> Columnar' (QGroupExpr be s) a
forall (f :: * -> *) a. Columnar f a -> Columnar' f a
Columnar' ((TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr QGroupingContext be s a
forall context be s t.
(TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr TablePrefix -> BeamSqlBackendExpressionSyntax be
x))
instance Beamable tbl =>
QGroupable (tbl (Nullable (QExpr be s))) (tbl (Nullable (QGroupExpr be s))) where
group_ :: tbl (Nullable (QExpr be s)) -> tbl (Nullable (QGroupExpr be s))
group_ = (forall a.
Columnar' (Nullable (QExpr be s)) a
-> Columnar' (Nullable (QGroupExpr be s)) a)
-> tbl (Nullable (QExpr be s)) -> tbl (Nullable (QGroupExpr be s))
forall (table :: (* -> *) -> *) (f :: * -> *) (g :: * -> *).
Beamable table =>
(forall a. Columnar' f a -> Columnar' g a) -> table f -> table g
changeBeamRep (\(Columnar' (QExpr x)) -> Columnar (Nullable (QGroupExpr be s)) a
-> Columnar' (Nullable (QGroupExpr be s)) a
forall (f :: * -> *) a. Columnar f a -> Columnar' f a
Columnar' ((TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr QGroupingContext be s (Maybe a)
forall context be s t.
(TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr TablePrefix -> BeamSqlBackendExpressionSyntax be
x))
allInGroup_ :: IsSql92AggregationSetQuantifierSyntax s
=> Maybe s
allInGroup_ :: Maybe s
allInGroup_ = Maybe s
forall a. Maybe a
Nothing
distinctInGroup_ :: IsSql92AggregationSetQuantifierSyntax s
=> Maybe s
distinctInGroup_ :: Maybe s
distinctInGroup_ = s -> Maybe s
forall a. a -> Maybe a
Just s
forall q. IsSql92AggregationSetQuantifierSyntax q => q
setQuantifierDistinct
allInGroupExplicitly_ :: IsSql92AggregationSetQuantifierSyntax s
=> Maybe s
allInGroupExplicitly_ :: Maybe s
allInGroupExplicitly_ = s -> Maybe s
forall a. a -> Maybe a
Just s
forall q. IsSql92AggregationSetQuantifierSyntax q => q
setQuantifierAll
min_ :: BeamSqlBackend be
=> QExpr be s a -> QAgg be s (Maybe a)
min_ :: QExpr be s a -> QAgg be s (Maybe a)
min_ = Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s a -> QAgg be s (Maybe a)
forall be s a.
BeamSqlBackend be =>
Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s a -> QAgg be s (Maybe a)
minOver_ Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
forall s. IsSql92AggregationSetQuantifierSyntax s => Maybe s
allInGroup_
max_ :: BeamSqlBackend be
=> QExpr be s a -> QAgg be s (Maybe a)
max_ :: QExpr be s a -> QAgg be s (Maybe a)
max_ = Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s a -> QAgg be s (Maybe a)
forall be s a.
BeamSqlBackend be =>
Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s a -> QAgg be s (Maybe a)
maxOver_ Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
forall s. IsSql92AggregationSetQuantifierSyntax s => Maybe s
allInGroup_
avg_ :: ( BeamSqlBackend be, Num a )
=> QExpr be s a -> QAgg be s (Maybe a)
avg_ :: QExpr be s a -> QAgg be s (Maybe a)
avg_ = Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s a -> QAgg be s (Maybe a)
forall be a s.
(BeamSqlBackend be, Num a) =>
Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s a -> QAgg be s (Maybe a)
avgOver_ Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
forall s. IsSql92AggregationSetQuantifierSyntax s => Maybe s
allInGroup_
sum_ :: ( BeamSqlBackend be, Num a )
=> QExpr be s a -> QAgg be s (Maybe a)
sum_ :: QExpr be s a -> QAgg be s (Maybe a)
sum_ = Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s a -> QAgg be s (Maybe a)
forall be a s.
(BeamSqlBackend be, Num a) =>
Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s a -> QAgg be s (Maybe a)
sumOver_ Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
forall s. IsSql92AggregationSetQuantifierSyntax s => Maybe s
allInGroup_
countAll_ :: ( BeamSqlBackend be, Integral a ) => QAgg be s a
countAll_ :: QAgg be s a
countAll_ = (TablePrefix -> BeamSqlBackendExpressionSyntax be) -> QAgg be s a
forall context be s t.
(TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
-> TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
forall expr. IsSql92AggregationExpressionSyntax expr => expr
countAllE)
count_ :: ( BeamSqlBackend be, Integral b )
=> QExpr be s a -> QAgg be s b
count_ :: QExpr be s a -> QAgg be s b
count_ (QExpr TablePrefix -> BeamSqlBackendExpressionSyntax be
over) = (TablePrefix -> BeamSqlBackendExpressionSyntax be) -> QAgg be s b
forall context be s t.
(TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (Maybe
(Sql92AggregationSetQuantifierSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))))
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
forall expr.
IsSql92AggregationExpressionSyntax expr =>
Maybe (Sql92AggregationSetQuantifierSyntax expr) -> expr -> expr
countE Maybe
(Sql92AggregationSetQuantifierSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))))
forall a. Maybe a
Nothing (Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)))
-> (TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)))
-> TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
TablePrefix -> BeamSqlBackendExpressionSyntax be
over)
cumeDist_ :: BeamSqlT612Backend be
=> QAgg be s Double
cumeDist_ :: QAgg be s Double
cumeDist_ = (TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QAgg be s Double
forall context be s t.
(TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (BeamSqlBackendExpressionSyntax be
-> TablePrefix -> BeamSqlBackendExpressionSyntax be
forall (f :: * -> *) a. Applicative f => a -> f a
pure BeamSqlBackendExpressionSyntax be
forall expr.
IsSql2003ExpressionAdvancedOLAPOperationsSyntax expr =>
expr
cumeDistAggE)
percentRank_ :: BeamSqlT612Backend be
=> QAgg be s Double
percentRank_ :: QAgg be s Double
percentRank_ = (TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QAgg be s Double
forall context be s t.
(TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (BeamSqlBackendExpressionSyntax be
-> TablePrefix -> BeamSqlBackendExpressionSyntax be
forall (f :: * -> *) a. Applicative f => a -> f a
pure BeamSqlBackendExpressionSyntax be
forall expr.
IsSql2003ExpressionAdvancedOLAPOperationsSyntax expr =>
expr
percentRankAggE)
denseRank_ :: ( BeamSqlT612Backend be, Integral a )
=> QAgg be s a
denseRank_ :: QAgg be s a
denseRank_ = (TablePrefix -> BeamSqlBackendExpressionSyntax be) -> QAgg be s a
forall context be s t.
(TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (BeamSqlBackendExpressionSyntax be
-> TablePrefix -> BeamSqlBackendExpressionSyntax be
forall (f :: * -> *) a. Applicative f => a -> f a
pure BeamSqlBackendExpressionSyntax be
forall expr.
IsSql2003ExpressionAdvancedOLAPOperationsSyntax expr =>
expr
denseRankAggE)
rowNumber_ :: ( BeamSql2003ExpressionBackend be, Integral a )
=> QAgg be s a
rowNumber_ :: QAgg be s a
rowNumber_ = (TablePrefix -> BeamSqlBackendExpressionSyntax be) -> QAgg be s a
forall context be s t.
(TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (Sql2003WindowFrameExpressionSyntax
(Sql2003ExpressionWindowFrameSyntax
(BeamSqlBackendExpressionSyntax be))
-> TablePrefix
-> Sql2003WindowFrameExpressionSyntax
(Sql2003ExpressionWindowFrameSyntax
(BeamSqlBackendExpressionSyntax be))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Sql2003WindowFrameExpressionSyntax
(Sql2003ExpressionWindowFrameSyntax
(BeamSqlBackendExpressionSyntax be))
forall expr. IsSql2003ExpressionSyntax expr => expr
rowNumberE)
rank_ :: ( BeamSqlT611Backend be, Integral a )
=> QAgg be s a
rank_ :: QAgg be s a
rank_ = (TablePrefix -> BeamSqlBackendExpressionSyntax be) -> QAgg be s a
forall context be s t.
(TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (BeamSqlBackendExpressionSyntax be
-> TablePrefix -> BeamSqlBackendExpressionSyntax be
forall (f :: * -> *) a. Applicative f => a -> f a
pure BeamSqlBackendExpressionSyntax be
forall expr.
IsSql2003ExpressionElementaryOLAPOperationsSyntax expr =>
expr
rankAggE)
minOver_, maxOver_
:: BeamSqlBackend be
=> Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s a -> QAgg be s (Maybe a)
minOver_ :: Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s a -> QAgg be s (Maybe a)
minOver_ Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
q (QExpr TablePrefix -> BeamSqlBackendExpressionSyntax be
a) = (TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QAgg be s (Maybe a)
forall context be s t.
(TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (Maybe
(Sql92AggregationSetQuantifierSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))))
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
forall expr.
IsSql92AggregationExpressionSyntax expr =>
Maybe (Sql92AggregationSetQuantifierSyntax expr) -> expr -> expr
minE Maybe
(Sql92AggregationSetQuantifierSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))))
Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
q (Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)))
-> (TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)))
-> TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
TablePrefix -> BeamSqlBackendExpressionSyntax be
a)
maxOver_ :: Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s a -> QAgg be s (Maybe a)
maxOver_ Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
q (QExpr TablePrefix -> BeamSqlBackendExpressionSyntax be
a) = (TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QAgg be s (Maybe a)
forall context be s t.
(TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (Maybe
(Sql92AggregationSetQuantifierSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))))
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
forall expr.
IsSql92AggregationExpressionSyntax expr =>
Maybe (Sql92AggregationSetQuantifierSyntax expr) -> expr -> expr
maxE Maybe
(Sql92AggregationSetQuantifierSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))))
Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
q (Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)))
-> (TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)))
-> TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
TablePrefix -> BeamSqlBackendExpressionSyntax be
a)
avgOver_, sumOver_
:: ( BeamSqlBackend be, Num a )
=> Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s a -> QAgg be s (Maybe a)
avgOver_ :: Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s a -> QAgg be s (Maybe a)
avgOver_ Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
q (QExpr TablePrefix -> BeamSqlBackendExpressionSyntax be
a) = (TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QAgg be s (Maybe a)
forall context be s t.
(TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (Maybe
(Sql92AggregationSetQuantifierSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))))
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
forall expr.
IsSql92AggregationExpressionSyntax expr =>
Maybe (Sql92AggregationSetQuantifierSyntax expr) -> expr -> expr
avgE Maybe
(Sql92AggregationSetQuantifierSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))))
Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
q (Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)))
-> (TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)))
-> TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
TablePrefix -> BeamSqlBackendExpressionSyntax be
a)
sumOver_ :: Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s a -> QAgg be s (Maybe a)
sumOver_ Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
q (QExpr TablePrefix -> BeamSqlBackendExpressionSyntax be
a) = (TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QAgg be s (Maybe a)
forall context be s t.
(TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (Maybe
(Sql92AggregationSetQuantifierSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))))
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
forall expr.
IsSql92AggregationExpressionSyntax expr =>
Maybe (Sql92AggregationSetQuantifierSyntax expr) -> expr -> expr
sumE Maybe
(Sql92AggregationSetQuantifierSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))))
Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
q (Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)))
-> (TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)))
-> TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
TablePrefix -> BeamSqlBackendExpressionSyntax be
a)
countOver_
:: ( BeamSqlBackend be, Integral b )
=> Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s a -> QAgg be s b
countOver_ :: Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s a -> QAgg be s b
countOver_ Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
q (QExpr TablePrefix -> BeamSqlBackendExpressionSyntax be
a) = (TablePrefix -> BeamSqlBackendExpressionSyntax be) -> QAgg be s b
forall context be s t.
(TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (Maybe
(Sql92AggregationSetQuantifierSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))))
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
forall expr.
IsSql92AggregationExpressionSyntax expr =>
Maybe (Sql92AggregationSetQuantifierSyntax expr) -> expr -> expr
countE Maybe
(Sql92AggregationSetQuantifierSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))))
Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
q (Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)))
-> (TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)))
-> TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
TablePrefix -> BeamSqlBackendExpressionSyntax be
a)
everyOver_, someOver_, anyOver_
:: BeamSql99AggregationBackend be
=> Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s SqlBool -> QAgg be s SqlBool
everyOver_ :: Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s SqlBool -> QAgg be s SqlBool
everyOver_ Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
q (QExpr TablePrefix -> BeamSqlBackendExpressionSyntax be
a) = (TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QAgg be s SqlBool
forall context be s t.
(TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> BeamSqlBackendExpressionSyntax be
-> BeamSqlBackendExpressionSyntax be
forall expr.
IsSql99AggregationExpressionSyntax expr =>
Maybe (Sql92AggregationSetQuantifierSyntax expr) -> expr -> expr
everyE Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
q (BeamSqlBackendExpressionSyntax be
-> BeamSqlBackendExpressionSyntax be)
-> (TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> TablePrefix
-> BeamSqlBackendExpressionSyntax be
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TablePrefix -> BeamSqlBackendExpressionSyntax be
a)
someOver_ :: Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s SqlBool -> QAgg be s SqlBool
someOver_ Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
q (QExpr TablePrefix -> BeamSqlBackendExpressionSyntax be
a) = (TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QAgg be s SqlBool
forall context be s t.
(TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> BeamSqlBackendExpressionSyntax be
-> BeamSqlBackendExpressionSyntax be
forall expr.
IsSql99AggregationExpressionSyntax expr =>
Maybe (Sql92AggregationSetQuantifierSyntax expr) -> expr -> expr
someE Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
q (BeamSqlBackendExpressionSyntax be
-> BeamSqlBackendExpressionSyntax be)
-> (TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> TablePrefix
-> BeamSqlBackendExpressionSyntax be
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TablePrefix -> BeamSqlBackendExpressionSyntax be
a)
anyOver_ :: Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s SqlBool -> QAgg be s SqlBool
anyOver_ Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
q (QExpr TablePrefix -> BeamSqlBackendExpressionSyntax be
a) = (TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QAgg be s SqlBool
forall context be s t.
(TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> BeamSqlBackendExpressionSyntax be
-> BeamSqlBackendExpressionSyntax be
forall expr.
IsSql99AggregationExpressionSyntax expr =>
Maybe (Sql92AggregationSetQuantifierSyntax expr) -> expr -> expr
anyE Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
q (BeamSqlBackendExpressionSyntax be
-> BeamSqlBackendExpressionSyntax be)
-> (TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> TablePrefix
-> BeamSqlBackendExpressionSyntax be
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TablePrefix -> BeamSqlBackendExpressionSyntax be
a)
filterWhere_ :: BeamSqlT611Backend be
=> QAgg be s a -> QExpr be s Bool -> QAgg be s a
filterWhere_ :: QAgg be s a -> QExpr be s Bool -> QAgg be s a
filterWhere_ QAgg be s a
agg QExpr be s Bool
cond = QAgg be s a -> QExpr be s SqlBool -> QAgg be s a
forall be s a.
BeamSqlT611Backend be =>
QAgg be s a -> QExpr be s SqlBool -> QAgg be s a
filterWhere_' QAgg be s a
agg (QExpr be s Bool -> QExpr be s SqlBool
forall context syntax s.
QGenExpr context syntax s Bool -> QGenExpr context syntax s SqlBool
sqlBool_ QExpr be s Bool
cond)
filterWhere_' :: BeamSqlT611Backend be
=> QAgg be s a -> QExpr be s SqlBool -> QAgg be s a
filterWhere_' :: QAgg be s a -> QExpr be s SqlBool -> QAgg be s a
filterWhere_' (QExpr TablePrefix -> BeamSqlBackendExpressionSyntax be
agg) (QExpr TablePrefix -> BeamSqlBackendExpressionSyntax be
cond) = (TablePrefix -> BeamSqlBackendExpressionSyntax be) -> QAgg be s a
forall context be s t.
(TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr ((BeamSqlBackendExpressionSyntax be
-> BeamSqlBackendExpressionSyntax be
-> BeamSqlBackendExpressionSyntax be)
-> (TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> (TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> TablePrefix
-> BeamSqlBackendExpressionSyntax be
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 BeamSqlBackendExpressionSyntax be
-> BeamSqlBackendExpressionSyntax be
-> BeamSqlBackendExpressionSyntax be
forall expr.
IsSql2003ExpressionElementaryOLAPOperationsSyntax expr =>
expr -> expr -> expr
filterAggE TablePrefix -> BeamSqlBackendExpressionSyntax be
agg TablePrefix -> BeamSqlBackendExpressionSyntax be
cond)
every_ :: BeamSql99AggregationBackend be
=> QExpr be s SqlBool -> QAgg be s SqlBool
every_ :: QExpr be s SqlBool -> QAgg be s SqlBool
every_ = Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s SqlBool -> QAgg be s SqlBool
forall be s.
BeamSql99AggregationBackend be =>
Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s SqlBool -> QAgg be s SqlBool
everyOver_ Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
forall s. IsSql92AggregationSetQuantifierSyntax s => Maybe s
allInGroup_
some_ :: BeamSql99AggregationBackend be
=> QExpr be s SqlBool -> QAgg be s SqlBool
some_ :: QExpr be s SqlBool -> QAgg be s SqlBool
some_ = Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s SqlBool -> QAgg be s SqlBool
forall be s.
BeamSql99AggregationBackend be =>
Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s SqlBool -> QAgg be s SqlBool
someOver_ Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
forall s. IsSql92AggregationSetQuantifierSyntax s => Maybe s
allInGroup_
any_ :: BeamSql99AggregationBackend be
=> QExpr be s SqlBool -> QAgg be s SqlBool
any_ :: QExpr be s SqlBool -> QAgg be s SqlBool
any_ = Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s SqlBool -> QAgg be s SqlBool
forall be s.
BeamSql99AggregationBackend be =>
Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
-> QExpr be s SqlBool -> QAgg be s SqlBool
anyOver_ Maybe (BeamSqlBackendAggregationQuantifierSyntax be)
forall s. IsSql92AggregationSetQuantifierSyntax s => Maybe s
allInGroup_