Interface ModelParallelCalculationFormulaItemContext
- All Superinterfaces:
ModelFormulaContextReadOnly
The
ModelParallelCalculationFormulaItemContext
is exposed to model parallel calculation logics through the model
binding.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
-
Method Summary
Modifier and TypeMethodDescriptionlong
loadTable
(DatamartContext.Table table, DatamartContext.Query query) Sample code:long
loadTable
(DatamartContext.Table table, DatamartContext.SqlQuery query) Sample code:long
loadTable
(DatamartContext.Table table, PipelineStage query, boolean truncate) Sample code:Methods inherited from interface ModelFormulaContextReadOnly
attachmentDownloadURL, currentStep, filterTreesContext, inputs, label, lookupTablesContext, outputs, pmmlContext, rContext, schedulesContext, table, tableNames, typedId, uniqueName
-
Method Details
-
calculationItem
ModelParallelCalculationFormulaItemContext.CalculationItem calculationItem()- Returns:
- the item currently calculated
- Since:
- 9.0 - Hurricane
-
loadTable
long loadTable(DatamartContext.Table table, DatamartContext.Query query) throws InterruptedException Sample code:
WARNING: the given query must be idempotent (e.g., using key columns on the table) as each item calculation may be run several times (by several nodes) and the ordering of their execution is also nondeterministic.def ctx = api.getDatamartContext() def query = ctx.newQuery(ctx.getDataSource("txDS")) .select("sku", "P") .select("SUM(amount)", "R") .where(Filter.equal("sku", model.calculationItem().inputs()['sku'])) def table = model.getTable('MyTable') def nbRowAdded = model.loadTable(table, query)
- Parameters:
table
- A table in this modelquery
- An idempotent query to load into the table- Returns:
- The number of row added
- Throws:
InterruptedException
- Since:
- 10.0 - Bee's Knees
- See Also:
-
loadTable
long loadTable(DatamartContext.Table table, DatamartContext.SqlQuery query) throws InterruptedException Sample code:
WARNING: the given query must be idempotent (e.g., using key columns on the table) as each item calculation may be run several times (by several nodes) and the ordering of their execution is also nondeterministic.def ctx = api.getDatamartContext() def t1 = ctx.newQuery(ctx.getDataSource("txDS")) .select("sku", "P") .select("SUM(amount)", "R") .where(Filter.equal("sku", model.calculationItem().inputs()['sku'])) 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)
- Parameters:
table
- A table in this modelquery
- An idempotent query to load into the table- Returns:
- The number of row added
- Throws:
InterruptedException
- Since:
- 10.0 - Bee's Knees
- See Also:
-
loadTable
long loadTable(DatamartContext.Table table, PipelineStage query, boolean truncate) throws InterruptedException Sample code:
WARNING: the given query must be idempotent (e.g., using key columns on the table) as each item calculation may be run several times (by several nodes) and the ordering of their execution is also nondeterministic.def qapi = api.queryApi() def ds = qapi.tables().dataSource("txDS") def query = qapi .source(ds, [ds.sku, ds.amount]) .aggregateBy({ t -> [t.sku] }, { t -> [t.sku.as("P"), qapi.exprs().sum(t.amount).as("R")] }) .sortBy { t -> [qapi.orders().ascNullsLast(t.P)] } def table = model.getTable('MyTable') def nbRowAdded = model.loadTable(table, query, false)
- Parameters:
table
- A table in this modelquery
- The query to load into the tabletruncate
- If the table should be truncated before loading- Returns:
- The number of row added
- Throws:
InterruptedException
- Since:
- 15.0 - Southside
- See Also:
-