Interface ModelFormulaContextReadWrite
-
- All Superinterfaces:
ModelFormulaContextReadOnly
- All Known Subinterfaces:
ModelCalculationFormulaContext
public interface ModelFormulaContextReadWrite extends ModelFormulaContextReadOnly
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DatamartContext.Table
addTable(String name, Map<String,Object> tableSpecs)
Add a table in the model.void
dropTable(DatamartContext.Table table)
long
loadTable(DatamartContext.Table table, DatamartContext.Query source, boolean truncate)
Sample code:long
loadTable(DatamartContext.Table table, DatamartContext.SqlQuery source, boolean truncate)
Sample code:void
startJobTriggerCalculation(String imageName, String imageTag, String parameters, String jobName)
It is the responsibility of the caller to serializeparameters
however they are required by the image.void
truncateTable(DatamartContext.Table table)
-
Methods inherited from interface ModelFormulaContextReadOnly
inputs, label, outputs, table, uniqueName
-
-
-
-
Method Detail
-
addTable
DatamartContext.Table addTable(String name, Map<String,Object> tableSpecs)
Add a table in the model. If the table already exists, it is replaced by this new table.A
Map
respecting the structure ofDMTable
, including:label
: the table labelfields
: aList
ofMap
respecting the structure ofDMField
, includingname
,label
,type
,format
,key
,dimension
Sample code:
model.addTable("RevenueByProduct", [ label: "Revenue By Product", // the fields must respect DMField structure fields: [ [ name:"productId", label:"Product ID", type:"TEXT", key:true], [ name:"productGroup", label:"ProductGroup", type:"TEXT", dimension:true], [ name:"revenue", label:"Revenue", type:"MONEY"], ] ])
- Parameters:
name
- The table name to be created in this modeltableSpecs
- The definition of the table to be created, see above.- Returns:
- The created model table
-
loadTable
long loadTable(DatamartContext.Table table, DatamartContext.Query source, boolean truncate)
Sample code:def ctx = api.getDatamartContext() def query = ctx.newQuery(ctx.getDataSource("txDS")) .select("sku", "P") .select("SUM(amount)", "R") def table = model.getTable('MyTable') def nbRowAdded = model.loadTable(table, query, false)
- Parameters:
table
- A table in this modelsource
- The query to load into the tabletruncate
- If the table should be truncated before loading- Returns:
- The number of row added
-
loadTable
long loadTable(DatamartContext.Table table, DatamartContext.SqlQuery source, boolean truncate)
Sample code:def ctx = api.getDatamartContext() def t1 = ctx.newQuery(ctx.getDataSource("txDS")) .select("sku", "P") .select("SUM(amount)", "R") def query = ctx.newSqlQuery() query.addSource(t1) query.setQuery('SELECT P, R::numeric as R FROM T1 ORDER BY P') def table = model.getTable('MyTable') def nbRowAdded = model.loadTable(table, query, false)
- Parameters:
table
- A table in this modelsource
- The query to load into the tabletruncate
- If the table should be truncated before loading- Returns:
- The number of row added
-
truncateTable
void truncateTable(DatamartContext.Table table)
- Parameters:
table
- A table in the model
-
dropTable
void dropTable(DatamartContext.Table table)
- Parameters:
table
- A table in the model
-
startJobTriggerCalculation
void startJobTriggerCalculation(String imageName, String imageTag, String parameters, String jobName)
It is the responsibility of the caller to serializeparameters
however they are required by the image.jobName
should be unique inside the step and model formula calculation that triggers them.Multiple job trigger calculation in a given formula calculation will run in parallel.
- Parameters:
imageName
- A docker image name, without the tagimageTag
- A tag for the docker image nameparameters
- Some parameters understood by the image usedjobName
- A name for the job, unique per current step and calculation
-
-