Using Table Parameters
Table parameters hold table data with rows and columns, much like a spreadsheet. Table parameters come in four types:
TableParameterType.Inline
- Table parameters of typeInline
hold a String value with anInline:
prefix followed by the XML data. Processing instructions<?...?>
are optional, however, must be followed by newline characters before the<table>
tag if specified.TableParameterType.JobFile
- Table parameters of typeJobFile
hold a String value with a prefixJobFile:
followed by reference to a process file (<ID>:<file_name>
) such asJobFile:1234:stdout.rtx
which evaluates to the filestdout.rtx
on process with ID1234
.TableParameterType.RelativeFile
- Table parameters of typeRelativeFile
hold a String value with a prefixRelativeFile:
followed by a file specification of a relative process such asRelative:<step_name>, Job <process_ID>:<file_name>
, for exampleRelativeFile:Initialization, Job 3:output.rtx
TableParameterType.Table
- Table parameters of typeTable
hold a BusinessKey of a table (Table:<partition>.<table>
), such asTable:MyPartition.MyTable
.
Prerequisites
- Table parameters are supported by the RedwoodScript process definition and certain Redwood Finance Automation-specific definition types
API
The TableParameterRuntime interface (Table parameters at Runtime) has getRTXReader()
and getRTXWriter()
methods that allow you to read and write Tables, respectively. Each column has a data type (String, DataeTimeZone, BigDecimal), the value of each row in a column must be convertible to the data type or the table will be considered invalid. See the com.redwood.scheduler.api.rtx
package for classes and how to use them.
Sample RTX File
<?xml version="1.0" encoding="UTF-8"?>
<table xmlns="http://schema.redwood.com/report/rtx.xsd">
<metadata>
<columns>
<column>
<name>symbol</name>
<string></string>
</column>
<column>
<name>value</name>
<number></number>
</column>
<column>
<name>date</name>
<date></date>
</column>
</columns>
</metadata>
<data>
<r><k></k><v>APPL</v><v>156.41</v><v>2023/09/28</v></r>
<r><k></k><v>SDY</v><v>93.14</v><v>2023/09/28</v></r>
<r><k></k><v>INTC</v><v>40.80</v><v>2023/09/28</v></r>
<r><k></k><v>BRKB</v><v>189.71</v><v>2023/09/28</v></r>
<r><k></k><v>FB</v><v>170.60</v><v>2023/09/28</v></r>
<r><k></k><v>GOOG</v><v>973.33</v><v>2023/09/28</v></r>
</data>
</table>
Writing an RTX File
This technique uses a Table parameter named outParameter
on the definition that is an Out parameter. The out value of the parameter will be set to a file reference ( JobFile:1234:stdout.rtx
). You use getRTXWriterInline()
if you want to have the table data inline.
import java.math.BigDecimal;
import com.redwood.scheduler.api.date.DateTimeZone;
import com.redwood.scheduler.api.rtx.*;
{
try (RTXWriter writer = outParameter.getRTXWriterToStandardOutput())
{
writer.addColumn(new RTXColumn("symbol", RTXType.String));
writer.addColumn(new RTXColumn("value", RTXType.Number));
writer.addColumn(new RTXColumn("date", RTXType.Date));
writer.addColumn(new RTXColumn("date2", RTXType.String));
DateTimeZone dtz = DateTimeZone.valueOf("2023/09/28 00:00:00,000 America/New_York");
String date2 = dtz.toFormattedString("dd-MM-yyyy");
writer.addRow(new Object [] { "AAPL", "156.41", dtz, date2, });
writer.addRow(new Object [] { "SDY", "93.14" , dtz, date2, });
writer.addRow(new Object [] { "INTC", "40.80" , dtz, date2, });
writer.addRow(new Object [] { "BRKB", "189.71", dtz, date2, });
writer.addRow(new Object [] { "FB", "170.60", dtz, date2, });
writer.addRow(new Object [] { "GOOG", "973.33", dtz, date2, });
}
}
See Also
Table Parameter JobParameter JobChainParameter JobDefinitionParameter ProcessDefinitionParameter