napkin-api-2.0.0
Safe HaskellNone
LanguageGHC2024

Napkin.Run.Effects.Programs

Synopsis

Documentation

splitIfUnionBy :: forall b (r :: EffectRow) a. Members '[SqlWrite b :: (Type -> Type) -> Type -> Type, RecreateTable b :: (Type -> Type) -> Type -> Type] r => Int -> Sem r a -> Sem r a #

Intercept CreateTableAs calls and try to split queries into CreateTableAs + multiple InsertInto when query contains unions

incrementalInsertByPK #

Arguments

:: forall b (r :: EffectRow). Members '[SqlWrite b :: (Type -> Type) -> Type -> Type, SqlRead b :: (Type -> Type) -> Type -> Type, Time :: (Type -> Type) -> Type -> Type, Reader TargetName, Reader HiddenDependencies, RecreateTable b :: (Type -> Type) -> Type -> Type] r 
=> (Day -> Sem r Query)

Query with cutoff

-> SExp

Primary key column

-> Day

Starting timestamp value in fresh create

-> Integer

Num days to look back in each update

-> BackendTableMeta b 
-> Sem r () 

incrementalByTimeRawSql #

Arguments

:: forall b (r :: EffectRow). (Members '[SqlWrite b :: (Type -> Type) -> Type -> Type, SqlRead b :: (Type -> Type) -> Type -> Type, Time :: (Type -> Type) -> Type -> Type, Reader TargetName, Reader HiddenDependencies, Reader HiddenArtifacts, RecreateTable b :: (Type -> Type) -> Type -> Type, SqlParse :: (Type -> Type) -> Type -> Type, SqlRender :: (Type -> Type) -> Type -> Type, LoadQuery :: (Type -> Type) -> Type -> Type, FatalError :: (Type -> Type) -> Type -> Type, Output ExtraDependencies :: (Type -> Type) -> Type -> Type, Input TemporaryTableName :: (Type -> Type) -> Type -> Type, Input MetaArguments :: (Type -> Type) -> Type -> Type, Log :: (Type -> Type) -> Type -> Type] r, Default (BackendTableMeta b)) 
=> 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

-> BackendTableMeta b 
-> Sem r () 

loadSqlFileWithCutoff :: forall (r :: EffectRow). Members '[SqlParse :: (Type -> Type) -> Type -> Type, SqlRender :: (Type -> Type) -> Type -> Type, FatalError :: (Type -> Type) -> Type -> Type, LoadQuery :: (Type -> Type) -> Type -> Type, Log :: (Type -> Type) -> Type -> Type] r => FilePath -> SqlTemplateVariables -> Day -> Sem r Query #

copyData :: forall b (r :: EffectRow). Member (SqlWrite b :: (Type -> Type) -> Type -> Type) r => Ref Table -> Ref Table -> Sem r () #

longToWideAuto #

Arguments

:: forall b (r :: EffectRow). Members '[SqlWrite b :: (Type -> Type) -> Type -> Type, SqlRead b :: (Type -> Type) -> Type -> Type, Reader HiddenDependencies, Reader TargetName, RecreateTable b :: (Type -> Type) -> Type -> Type] r 
=> 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 to use

-> [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

-> Sem r () 

combineTables #

Arguments

:: forall b (r :: EffectRow). (Members '[SqlWrite b :: (Type -> Type) -> Type -> Type, SqlRead b :: (Type -> Type) -> Type -> Type, Output ExtraDependencies :: (Type -> Type) -> Type -> Type, Reader TargetName, RecreateTable b :: (Type -> Type) -> Type -> Type, Input TemporaryTableName :: (Type -> Type) -> Type -> Type, Reader QueryTransformer] r, HasBackendSchemaField b) 
=> SpecTarget b 
-> (Query -> Query)

Any final optional query modification

-> [Relation]

List of sources to combine

-> Sem r () 

external :: forall {k} (b :: k) (r :: EffectRow). Members '[FatalError :: (Type -> Type) -> Type -> Type, SqlRead b :: (Type -> Type) -> Type -> Type, External :: (Type -> Type) -> Type -> Type, Reader TargetName, Output ExtraDependencies :: (Type -> Type) -> Type -> Type, Input MetaArguments :: (Type -> Type) -> Type -> Type] r => Set (Ref Table) -> ExternalCommand -> Sem r () #

recreateTarget :: forall b (r :: EffectRow). Members '[RecreateTable b :: (Type -> Type) -> Type -> Type, Reader TargetName, SqlWrite b :: (Type -> Type) -> Type -> Type] r => SpecTarget b -> NonEmpty Query -> Sem r () #

pattern IncrementalReset :: (Eq a, IsString a) => a #

enforceSchema :: forall b (r :: EffectRow). (Members '[Input TemporaryTableName :: (Type -> Type) -> Type -> Type, SqlRead b :: (Type -> Type) -> Type -> Type, SqlWrite b :: (Type -> Type) -> Type -> Type, FatalError :: (Type -> Type) -> Type -> Type, Log :: (Type -> Type) -> Type -> Type] r, HasBackendSchemaField b, Eq (BackendSchemaField b)) => EnforceSchemaOptions -> Ref Table -> [BackendSchemaField b] -> Sem r () #

data EnforceSchemaOptions #

Instances

Instances details
Generic EnforceSchemaOptions # 
Instance details

Defined in Napkin.Run.Effects.Programs

Associated Types

type Rep EnforceSchemaOptions 
Instance details

Defined in Napkin.Run.Effects.Programs

type Rep EnforceSchemaOptions = D1 ('MetaData "EnforceSchemaOptions" "Napkin.Run.Effects.Programs" "napkin-api-2.0.0-1rW5o7bIFjJ3ZPvUF06Wka" 'False) (C1 ('MetaCons "EnforceSchemaOptions" 'PrefixI 'True) (S1 ('MetaSel ('Just "dropColumnsPolicy") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DroppedColumnPolicy) :*: S1 ('MetaSel ('Just "addColumnsPolicy") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 AddedColumnPolicy)))
Show EnforceSchemaOptions # 
Instance details

Defined in Napkin.Run.Effects.Programs

Eq EnforceSchemaOptions # 
Instance details

Defined in Napkin.Run.Effects.Programs

type Rep EnforceSchemaOptions # 
Instance details

Defined in Napkin.Run.Effects.Programs

type Rep EnforceSchemaOptions = D1 ('MetaData "EnforceSchemaOptions" "Napkin.Run.Effects.Programs" "napkin-api-2.0.0-1rW5o7bIFjJ3ZPvUF06Wka" 'False) (C1 ('MetaCons "EnforceSchemaOptions" 'PrefixI 'True) (S1 ('MetaSel ('Just "dropColumnsPolicy") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DroppedColumnPolicy) :*: S1 ('MetaSel ('Just "addColumnsPolicy") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 AddedColumnPolicy)))

data AddedColumnPolicy #

Constructors

AddColumns 
ForbidAdding 

Instances

Instances details
Generic AddedColumnPolicy # 
Instance details

Defined in Napkin.Run.Effects.Programs

Associated Types

type Rep AddedColumnPolicy 
Instance details

Defined in Napkin.Run.Effects.Programs

type Rep AddedColumnPolicy = D1 ('MetaData "AddedColumnPolicy" "Napkin.Run.Effects.Programs" "napkin-api-2.0.0-1rW5o7bIFjJ3ZPvUF06Wka" 'False) (C1 ('MetaCons "AddColumns" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ForbidAdding" 'PrefixI 'False) (U1 :: Type -> Type))
Show AddedColumnPolicy # 
Instance details

Defined in Napkin.Run.Effects.Programs

Eq AddedColumnPolicy # 
Instance details

Defined in Napkin.Run.Effects.Programs

type Rep AddedColumnPolicy # 
Instance details

Defined in Napkin.Run.Effects.Programs

type Rep AddedColumnPolicy = D1 ('MetaData "AddedColumnPolicy" "Napkin.Run.Effects.Programs" "napkin-api-2.0.0-1rW5o7bIFjJ3ZPvUF06Wka" 'False) (C1 ('MetaCons "AddColumns" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ForbidAdding" 'PrefixI 'False) (U1 :: Type -> Type))

data DroppedColumnPolicy #

Constructors

KeepColumns 
DropColumns 

Instances

Instances details
Generic DroppedColumnPolicy # 
Instance details

Defined in Napkin.Run.Effects.Programs

Associated Types

type Rep DroppedColumnPolicy 
Instance details

Defined in Napkin.Run.Effects.Programs

type Rep DroppedColumnPolicy = D1 ('MetaData "DroppedColumnPolicy" "Napkin.Run.Effects.Programs" "napkin-api-2.0.0-1rW5o7bIFjJ3ZPvUF06Wka" 'False) (C1 ('MetaCons "KeepColumns" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DropColumns" 'PrefixI 'False) (U1 :: Type -> Type))
Show DroppedColumnPolicy # 
Instance details

Defined in Napkin.Run.Effects.Programs

Eq DroppedColumnPolicy # 
Instance details

Defined in Napkin.Run.Effects.Programs

type Rep DroppedColumnPolicy # 
Instance details

Defined in Napkin.Run.Effects.Programs

type Rep DroppedColumnPolicy = D1 ('MetaData "DroppedColumnPolicy" "Napkin.Run.Effects.Programs" "napkin-api-2.0.0-1rW5o7bIFjJ3ZPvUF06Wka" 'False) (C1 ('MetaCons "KeepColumns" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DropColumns" 'PrefixI 'False) (U1 :: Type -> Type))