napkin-0.5.9
Copyright(c) Soostone Inc 2020
LicenseAllRightsReserved
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Napkin.Spec

Description

 
Synopsis

Documentation

spec :: Ref Table -> TableSpec b #

shorthand for starting specs, use lenses to then update parts

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.

specIncrementalByPK #

Arguments

:: 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 #

specIncrementalByTimeRawSql #

Arguments

:: 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.

longToWideAutoSpec #

Arguments

:: 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.

commandSpec #

Arguments

:: 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.

combineTablesSpec #

Arguments

:: 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.

addHooks :: [([Ref Table], HookProgram b)] -> Spec b () #

addTags :: [TableSpecTag] -> Spec b () -> Spec b () #

newtype SqlTemplateVariables #

Instances

Instances details
Eq SqlTemplateVariables # 
Instance details

Defined in Napkin.Parse.Interpolation.Types

Ord SqlTemplateVariables # 
Instance details

Defined in Napkin.Parse.Interpolation.Types

Show SqlTemplateVariables # 
Instance details

Defined in Napkin.Parse.Interpolation.Types

Semigroup SqlTemplateVariables # 
Instance details

Defined in Napkin.Parse.Interpolation.Types

Monoid SqlTemplateVariables # 
Instance details

Defined in Napkin.Parse.Interpolation.Types

ToJSON SqlTemplateVariables # 
Instance details

Defined in Napkin.Parse.Interpolation.Types

FromJSON SqlTemplateVariables # 
Instance details

Defined in Napkin.Parse.Interpolation.Types

Default SqlTemplateVariables # 
Instance details

Defined in Napkin.Parse.Interpolation.Types

sqlVar :: ToJSON a => Text -> a -> (Text, Value) #