napkin-1.0.0
Safe HaskellNone
LanguageGHC2021

Napkin.Spec

Synopsis

Documentation

spec :: SpecTableName -> 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

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

Arguments

:: Default (BackendTableMeta b) 
=> (Day -> CreateTableAs b)

How to create/form the target table with data newer than the given cutoff date

-> (Day -> SExp)

Filter in (DELETE WHERE) to be used when deleting data newer than the given cutoff date in the target table.

-> Day

Overall start date to use when starting fresh

-> Integer

Number of days to go back and refresh each time update is run

-> [Ref Table]

Custom additional dependencies to be included (legacy)

-> TableSpec b 

specIncrementalByTimeRawSql #

Arguments

:: Default (BackendTableMeta b) 
=> SpecTableName

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 :: SpecTableName -> 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 :: SpecTableName -> SpecTarget b -> FilePath -> SqlTemplateVariables -> [Ref Table] -> TableSpec b #

Same as rawSqlSpec but allows for mustache templating inside of the raw SQL file.

longToWideAutoSpec #

Arguments

:: SpecTableName

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)

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

commandSpec #

Arguments

:: SpecTableName

the name of the new table

-> Text

command

-> [Text]

arguments

-> [Ref Table]

the list of dependencies - these cannot be deduced

-> TableSpec b 

A custom Spec which runs a command to create a table

shellSpec #

Arguments

:: SpecTableName

the name of the new table

-> Text

command

-> [Ref Table]

the list of dependencies - these cannot be deduced

-> TableSpec b 

A custom Spec which runs a shell script to create a table

combineTablesSpec #

Arguments

:: HasBackendSchemaField b 
=> SpecTableName 
-> 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.

addHooks :: [(Text, [SpecTableName], GlobalHookProgram b)] -> Spec b () #

Adds global hook, description, dependencies and hook's specification

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

withParsedMetaArg :: (FromJSON a, Typeable a) => (a -> Spec b c) -> Spec b c #

newtype SqlTemplateVariables #

Instances

Instances details
FromJSON SqlTemplateVariables # 
Instance details

Defined in Napkin.Parse.Interpolation.Types

ToJSON SqlTemplateVariables # 
Instance details

Defined in Napkin.Parse.Interpolation.Types

Monoid SqlTemplateVariables # 
Instance details

Defined in Napkin.Parse.Interpolation.Types

Semigroup SqlTemplateVariables # 
Instance details

Defined in Napkin.Parse.Interpolation.Types

Show SqlTemplateVariables # 
Instance details

Defined in Napkin.Parse.Interpolation.Types

Default SqlTemplateVariables # 
Instance details

Defined in Napkin.Parse.Interpolation.Types

Eq SqlTemplateVariables # 
Instance details

Defined in Napkin.Parse.Interpolation.Types

Ord SqlTemplateVariables # 
Instance details

Defined in Napkin.Parse.Interpolation.Types

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