Copyright | (c) Soostone Inc 2020 |
---|---|
License | AllRightsReserved |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- combineTablesLeft :: DefinedRelation -> [(DefinedRelation, Ref Relation -> Ref Relation -> SExp)] -> Q ()
- columnsToRows :: DefinedRelation -> [String] -> Query
- unionTables :: [DefinedRelation] -> Query
- unionWithSchema :: [(Relation, Fields Field)] -> Query
- unifySchemas :: [(Relation, Fields Field)] -> [Query]
- castToField :: Field -> SExp -> SExp
- filterFields :: (Ref t -> Bool) -> Query -> Query
- whitelistFields :: Foldable t1 => t1 Regex -> Ref t -> Bool
- longToWideFormat :: (SExp -> SExp) -> [Alias SExp] -> [(SExp, SExp, Ref SExp)] -> Query -> Query
- longToWideFormatSimple :: (SExp -> SExp) -> [Alias SExp] -> [(SExp, SExp)] -> Ref SExp -> SExp -> Query -> Query
- simpleValueAsColumnName :: Text -> Value -> Ref SExp
- splitUnions :: Foldable t => Int -> t Query -> [Query]
Documentation
:: DefinedRelation | |
-> [(DefinedRelation, Ref Relation -> Ref Relation -> SExp)] | Table definitions and primary keys each shares with the first table in list |
-> Q () |
Combine multiple tables/queries that were defined in napkin that share a common set of primary keys via a chain of left joins.
:: DefinedRelation | |
-> [String] | Groups, keep these intact on each row |
-> Query |
Transfroms columns into separate rows, per given partition
unionTables :: [DefinedRelation] -> Query #
Combine all tables into one assuming if the field names are the same, their types will just work out. Fill missing columns with NULL on a per-table basis.
unionWithSchema :: [(Relation, Fields Field)] -> Query #
Unify schemas and join given relations under a single UNION query.
unifySchemas :: [(Relation, Fields Field)] -> [Query] #
Given relations' and their known schema, whether it's a Query
or a table reference, union them in a way that works out the
missing columns in each and even unifies mis-matching types to a
common denominator.
castToField :: Field -> SExp -> SExp #
Cast expression bsaed on a desired type from the sql-schema
library.
filterFields :: (Ref t -> Bool) -> Query -> Query #
Only keep selected fields in Query that pass the predicate.
whitelistFields :: Foldable t1 => t1 Regex -> Ref t -> Bool #
Keep any field that matches any of the given regexes. Can use
this to construct the predicate in filterFields
longToWideFormat :: (SExp -> SExp) -> [Alias SExp] -> [(SExp, SExp, Ref SExp)] -> Query -> Query #
Convert a "long" query to "wide" by aggregating/matching over certain SExps.
longToWideFormatSimple :: (SExp -> SExp) -> [Alias SExp] -> [(SExp, SExp)] -> Ref SExp -> SExp -> Query -> Query #
A long-to-wide query transformer which matches using equality
simpleValueAsColumnName :: Text -> Value -> Ref SExp #
A basic means of generating new column names from
splitUnions :: Foldable t => Int -> t Query -> [Query] #
Given a list of queries that may contain any number of top level UNIONs, chunk them into queries where each contains at most N unions.
Useful for reducing/capping the size of each top level query so they can be sent individually to the database.