Copyright | (c) Soostone Inc 2020 |
---|---|
License | AllRightsReserved |
Stability | experimental |
Portability | POSIX |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
Synopsis
- (||.) :: SExp -> SExp -> SExp
- concatPortable :: [SExp] -> SExp
- avg :: SExp -> SExp
- max :: SExp -> SExp
- min :: SExp -> SExp
- sum :: SExp -> SExp
- count :: SExp -> SExp
- countd :: SExp -> SExp
- nullary :: Ref Function -> SExp
- unary :: Ref Function -> SExp -> SExp
- binary :: Ref Function -> SExp -> SExp -> SExp
- triple :: Ref Function -> SExp -> SExp -> SExp -> SExp
- quaternary :: Ref Function -> SExp -> SExp -> SExp -> SExp -> SExp
- multiple :: Ref Function -> [SExp] -> SExp
- raw :: String -> SExp
- true :: SExp
- false :: SExp
- type SExp_ (a :: Symbol) = SExp
- multiple_12 :: Ref Function -> SExp -> Maybe SExp -> SExp
- simpleWindow :: Ref Function -> [SExp] -> WOver -> Maybe NullStrategy -> SExp
- modExtern :: Ref Function -> [SExp] -> [FunModifier] -> SExp
- case_ :: [(SExp, SExp)] -> SExp -> SExp
- caseMatch_ :: SExp -> [(SExp, SExp)] -> SExp -> SExp
- if_ :: SExp -> SExp -> SExp -> SExp
- sign :: SExp -> SExp
- (/.) :: SExp -> SExp -> SExp
- cast :: SExp -> Type -> SExp
- asText :: SExp -> SExp
- asDouble :: SExp -> SExp
- asInt :: SExp -> SExp
- asBool :: SExp -> SExp
- asDate :: SExp -> SExp
- asTimestamp :: SExp -> SExp
- (==.) :: SExp -> SExp -> SExp
- (/=.) :: SExp -> SExp -> SExp
- (>=.) :: SExp -> SExp -> SExp
- (>.) :: SExp -> SExp -> SExp
- (<=.) :: SExp -> SExp -> SExp
- (<.) :: SExp -> SExp -> SExp
- is :: SExp -> SExp -> SExp
- isNot :: SExp -> SExp -> SExp
- isNull :: SExp -> SExp
- notNull :: SExp -> SExp
- exists :: Query -> SExp
- notExists :: Query -> SExp
- in_ :: SExp -> [SExp] -> SExp
- notIn :: SExp -> [SExp] -> SExp
- always :: SExp
- never :: SExp
- any_ :: SExp -> SExp
- all_ :: SExp -> SExp
- some_ :: SExp -> SExp
- not :: SExp -> SExp
- (.&&.) :: SExp -> SExp -> SExp
- (.||.) :: SExp -> SExp -> SExp
- and :: [SExp] -> SExp
- or :: [SExp] -> SExp
- maxOf :: SExp -> SExp -> SExp
- minOf :: SExp -> SExp -> SExp
- hardCount :: SExp
- valueIf :: SExp -> SExp -> SExp -> SExp
- nullifyUnless :: SExp -> SExp -> SExp
- nullifyIf :: SExp -> SExp -> SExp
- nullifyIfEmpty :: SExp -> SExp
- deepApply :: (SExp -> SExp) -> SExp -> SExp
- isEmpty :: SExp -> SExp
- notEmpty :: SExp -> SExp
- countTrue :: SExp -> SExp
- boolToInt :: SExp -> SExp
- coalesce :: [SExp] -> SExp
- scopeGeneric :: [(Ref Function, SExp)] -> SExp -> SExp -> SExp
- data BackendFunctionMeta = BackendFunctionMeta {}
- backendFunctionMeta_analytics :: Lens' BackendFunctionMeta [Ref Function]
- backendFunctionMeta_aggs :: Lens' BackendFunctionMeta [(Ref Function, SExp)]
- inferAggGeneric :: BackendFunctionMeta -> SExp -> AggLevel
- unitBoundaryGeneric :: BackendFunctionMeta -> SExp -> [SExp]
- modifyUnitBoundaryGeneric :: BackendFunctionMeta -> (SExp -> SExp) -> SExp -> SExp
Documentation
concatPortable :: [SExp] -> SExp #
"portable" concat for backends that do not have a native concat function.
simpleWindow :: Ref Function -> [SExp] -> WOver -> Maybe NullStrategy -> SExp #
asTimestamp :: SExp -> SExp #
nullifyUnless :: SExp -> SExp -> SExp #
Set to null unless predicate in first argument is true
nullifyIfEmpty :: SExp -> SExp #
Make empty string NULL.
deepApply :: (SExp -> SExp) -> SExp -> SExp #
Apply a function on Lits and Vars, recursing deep into function calls, etc.
Common case of a string column possibly being empty either by being a blank string or properly being NULL.
scopeGeneric :: [(Ref Function, SExp)] -> SExp -> SExp -> SExp #
Apply a given predicate condition deeply within a given expression, such that the predicate is pushed inside all the aggregating function calls in SQL.
This makes it possible to have conditional aggregations without needing additional CTEs.
TODO. This is may have holes; we need a principled end-to-end review of this transformation. Perhaps even put it as a primitive into the SExp type.
data BackendFunctionMeta #
BackendFunctionMeta | |
|
Instances
Show BackendFunctionMeta # | |
Defined in Napkin.Untyped.Ops showsPrec :: Int -> BackendFunctionMeta -> ShowS # show :: BackendFunctionMeta -> String # showList :: [BackendFunctionMeta] -> ShowS # | |
Eq BackendFunctionMeta # | |
Defined in Napkin.Untyped.Ops (==) :: BackendFunctionMeta -> BackendFunctionMeta -> Bool # (/=) :: BackendFunctionMeta -> BackendFunctionMeta -> Bool # |
inferAggGeneric :: BackendFunctionMeta -> SExp -> AggLevel #
Infer aggregation level of an expression.
TODO: ExternRaw and NativeExpr cant be inferred at the moment; needs more info inside the SExp if this becomes a problem.
unitBoundaryGeneric :: BackendFunctionMeta -> SExp -> [SExp] #
Explore expression's insides to pull out top level Unit
expressions within its branches, but no deeper in each branch.
Originally created to help with common expression caching - since you can commonolize unit-level expressions without any side-effect.
modifyUnitBoundaryGeneric :: BackendFunctionMeta -> (SExp -> SExp) -> SExp -> SExp #