Copyright | (c) Soostone Inc 2020 |
---|---|
License | AllRightsReserved |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- spec :: Ref Table -> TableSpec b
- ctaToSpec :: IsBackendTableMeta b => CreateTableAs b -> TableSpec b
- tableWithQuery :: Ref Table -> Query -> TableSpec b
- tableWithQueryAndMeta :: IsBackendTableMeta b => BackendTableMeta b -> Ref Table -> Query -> TableSpec b
- programToSpec :: Ref Table -> SpecProgram b -> TableSpec b
- viewWithQuery :: Ref Table -> Query -> TableSpec b
- specSplitIfUnion :: TableSpec b0 -> TableSpec b0
- specSplitIfUnionBy :: Int -> TableSpec b0 -> TableSpec b0
- specIncrementalByPK :: forall b. IsBackendTableMeta b => (Day -> CreateTableAs b) -> SExp -> Day -> Integer -> TableSpec b
- specIncrementalByTime :: forall b. IsBackendTableMeta b => (Day -> CreateTableAs b) -> (Day -> SExp) -> Day -> Integer -> [Ref Table] -> TableSpec b
- specIncrementalByTimeRawSql :: forall b. IsBackendTableMeta b => Ref Table -> Maybe (BackendTableMeta b) -> [Ref Table] -> FilePath -> SqlTemplateVariables -> SExp -> Day -> Integer -> TableSpec b
- rawSqlSpec :: forall b. IsBackendTableMeta b => Ref Table -> Maybe (BackendTableMeta b) -> FilePath -> SpecTarget -> [Ref Table] -> TableSpec b
- rawSqlMustacheSpec :: forall b. IsBackendTableMeta b => Ref Table -> Maybe (BackendTableMeta b) -> FilePath -> SqlTemplateVariables -> SpecTarget -> [Ref Table] -> TableSpec b
- longToWideAutoSpec :: forall b. IsBackendTableMeta b => Ref Table -> Ref Table -> (SExp -> SExp) -> [Alias SExp] -> SExp -> SExp -> (Value -> Ref SExp) -> Maybe (BackendTableMeta b) -> SpecTarget -> [Ref Table] -> TableSpec b
- commandSpec :: forall b. Ref Table -> String -> [String] -> [Ref Table] -> TableSpec b
- combineTablesSpec :: forall bk. Ref Table -> SpecTarget -> (Query -> Query) -> [Relation] -> TableSpec bk
- 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 :: IsBackendTableMeta b => CreateTableAs b -> TableSpec b #
tableWithQueryAndMeta :: IsBackendTableMeta b => BackendTableMeta b -> Ref Table -> Query -> TableSpec b #
programToSpec :: Ref Table -> SpecProgram b -> 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. IsBackendTableMeta 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. IsBackendTableMeta b => (Day -> CreateTableAs b) -> (Day -> SExp) -> Day -> Integer -> [Ref Table] -> TableSpec b #
:: forall b. IsBackendTableMeta b | |
=> Ref Table | Name of the backend, required for sql rendering |
-> Maybe (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. IsBackendTableMeta b => Ref Table -> Maybe (BackendTableMeta b) -> FilePath -> SpecTarget -> [Ref Table] -> TableSpec b #
Read a file that contains raw SQL query code that can be used to instantiate a table.
rawSqlMustacheSpec :: forall b. IsBackendTableMeta b => Ref Table -> Maybe (BackendTableMeta b) -> FilePath -> SqlTemplateVariables -> SpecTarget -> [Ref Table] -> TableSpec b #
Same as rawSqlSpec
but allows for mustache templating inside of
the raw SQL file.
:: forall b. IsBackendTableMeta 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 |
-> Maybe (BackendTableMeta b) | standard table options |
-> SpecTarget | create a view or table |
-> [Ref 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 bk. Ref Table | |
-> SpecTarget | |
-> (Query -> Query) | Any final optional query modification |
-> [Relation] | List of sources to combine |
-> TableSpec bk |
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 #