Copyright | (c) Soostone Inc 2020 |
---|---|
License | AllRightsReserved |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- spec :: Ref Table -> TableSpec b
- ctaToSpec :: Default (BackendTableMeta b) => CreateTableAs b -> TableSpec b
- tableWithQuery :: Default (BackendTableMeta b) => Ref Table -> Query -> TableSpec b
- tableWithQueryAndMeta :: BackendTableMeta b -> Ref Table -> Query -> TableSpec b
- programToSpec :: Ref Table -> SpecProgram b -> TableSpec b
- viewWithQuery :: Default (BackendViewMeta b) => Ref Table -> Query -> TableSpec b
- specSplitIfUnion :: TableSpec b0 -> TableSpec b0
- specSplitIfUnionBy :: Int -> TableSpec b0 -> TableSpec b0
- specIncrementalByPK :: forall b. Default (BackendTableMeta b) => (Day -> CreateTableAs b) -> SExp -> Day -> Integer -> TableSpec b
- specIncrementalByTime :: forall b. Default (BackendTableMeta b) => (Day -> CreateTableAs b) -> (Day -> SExp) -> Day -> Integer -> [Ref Table] -> TableSpec b
- specIncrementalByTimeRawSql :: forall b. Default (BackendTableMeta b) => Ref Table -> BackendTableMeta b -> [Ref Table] -> FilePath -> SqlTemplateVariables -> SExp -> Day -> Integer -> TableSpec b
- rawSqlSpec :: forall b. Default (BackendTableMeta b) => Ref Table -> SpecTarget b -> FilePath -> [Ref Table] -> TableSpec b
- rawSqlMustacheSpec :: forall b. Default (BackendTableMeta b) => Ref Table -> SpecTarget b -> FilePath -> SqlTemplateVariables -> [Ref Table] -> TableSpec b
- longToWideAutoSpec :: forall b. Default (BackendTableMeta b) => Ref Table -> Ref Table -> (SExp -> SExp) -> [Alias SExp] -> SExp -> SExp -> (Value -> Ref SExp) -> SpecTarget b -> [Ref Table] -> TableSpec b
- commandSpec :: forall b. Ref Table -> String -> [String] -> [Ref Table] -> TableSpec b
- combineTablesSpec :: forall b. Ref Table -> SpecTarget b -> (Query -> Query) -> [Relation] -> TableSpec b
- defineTable :: TableSpec b -> Spec b ()
- addHooks :: [([Ref Table], HookProgram b)] -> Spec b ()
- addTags :: [TableSpecTag] -> Spec b () -> Spec b ()
- module Napkin.Spec.Types
- type MonadCombo m = (MonadFix m, MonadBaseControl IO m, MonadIO m, MonadMask m, MonadFail m)
- newtype SqlTemplateVariables = SqlTemplateVariables {}
- sqlTemplate :: [(Text, Value)] -> SqlTemplateVariables
- sqlVar :: ToJSON a => Text -> a -> (Text, Value)
Documentation
ctaToSpec :: Default (BackendTableMeta b) => CreateTableAs b -> TableSpec b #
tableWithQuery :: Default (BackendTableMeta b) => Ref Table -> Query -> TableSpec b #
tableWithQueryAndMeta :: BackendTableMeta b -> Ref Table -> Query -> TableSpec b #
programToSpec :: Ref Table -> SpecProgram b -> TableSpec b #
viewWithQuery :: Default (BackendViewMeta b) => Ref Table -> Query -> TableSpec b #
specSplitIfUnion :: TableSpec b0 -> TableSpec b0 #
Split UNION queries and insert each individually.
specSplitIfUnionBy :: Int -> TableSpec b0 -> TableSpec b0 #
Split a top level UNION based query table definition into individual insert-based queries in chunks of n.
:: forall b. Default (BackendTableMeta b) | |
=> (Day -> CreateTableAs b) | Make me a query given a date cutoff |
-> SExp | Expression that produces the identity/primary key for this table |
-> Day | A start date if the table needs to be freshly created |
-> Integer | # of days to go back and refresh each time update is run |
-> TableSpec b |
specIncrementalByTime :: forall b. Default (BackendTableMeta b) => (Day -> CreateTableAs b) -> (Day -> SExp) -> Day -> Integer -> [Ref Table] -> TableSpec b #
:: forall b. Default (BackendTableMeta b) | |
=> Ref Table | Name of the backend, required for sql rendering |
-> BackendTableMeta b | Any backend specific table options |
-> [Ref Table] | Table's dependencies |
-> FilePath | Local SQL file |
-> SqlTemplateVariables | Any additional variables you want to bind |
-> SExp | Timestamp column in the destination table |
-> Day | Start time when creating table fresh |
-> Integer | N days to go bac |
-> TableSpec b |
rawSqlSpec :: forall b. Default (BackendTableMeta b) => Ref Table -> SpecTarget b -> FilePath -> [Ref Table] -> TableSpec b #
Read a file that contains raw SQL query code that can be used to instantiate a table.
rawSqlMustacheSpec :: forall b. Default (BackendTableMeta b) => Ref Table -> SpecTarget b -> FilePath -> SqlTemplateVariables -> [Ref Table] -> TableSpec b #
Same as rawSqlSpec
but allows for mustache templating inside of
the raw SQL file.
:: forall b. Default (BackendTableMeta b) | |
=> Ref Table | the new table to create |
-> Ref Table | the long table from which this table will be derived- make sure it is also listed in the dependencies |
-> (SExp -> SExp) | Aggergate function |
-> [Alias SExp] | the key columns which will remain in the resultant wide version as-is |
-> SExp | the column name in the long table which will be split into multiple columns in the wide version |
-> SExp | the column in the long table which will be emitted from matching on the new columns |
-> (Value -> Ref SExp) | a function to generate column names from the values found in the database |
-> SpecTarget b | standard table options |
-> [Ref Table] | create a view or table | this table's dependencies (include the long table) |
-> TableSpec b |
Query the "long" version of the table to determine what columns to put in the "wide" version. This function does not support mustache templates.
:: forall b. Ref Table | the name of the new table |
-> String | command |
-> [String] | command arguments |
-> [Ref Table] | the list of dependencies - these cannot be deduced |
-> TableSpec b |
A custom Spec which runs a command processed with mustache with the metaargs dictionary.
:: forall b. Ref Table | |
-> SpecTarget b | |
-> (Query -> Query) | Any final optional query modification |
-> [Relation] | List of sources to combine |
-> TableSpec b |
Specialized convenience for UNION-ing several tables and queries,
even for cases where the list of fields available in each table is
not known at compile time. This will introspect list of fields for
cases where a bare table name is given instead of a QueryRelation
.
defineTable :: TableSpec b -> Spec b () #
addTags :: [TableSpecTag] -> Spec b () -> Spec b () #
module Napkin.Spec.Types
type MonadCombo m = (MonadFix m, MonadBaseControl IO m, MonadIO m, MonadMask m, MonadFail m) #
newtype SqlTemplateVariables #
Instances
sqlTemplate :: [(Text, Value)] -> SqlTemplateVariables #