Primeur Online Docs
Data Shaper
Data Shaper
  • 🚀GETTING STARTED
    • What is Primeur Data Shaper
      • What is the Data Shaper Designer
      • What is the Data Shaper Server
      • What is the Data Shaper Cluster
    • How does the Data Shaper Designer work
      • Designer Views and Graphs
      • Data Shaper Graphs
      • Designer Projects and Sandboxes
      • Data Shaper Designer Reference
    • How do the Data Shaper Server and Cluster work
      • Data Shaper Server and Cluster
      • Data Shaper Server Reference
    • VFS Graph Components
      • DataOneFileDescriptor (DOFD) metadata
      • Passing parameters from Data One Contract to Data Shaper graph
      • Inheriting Data One context attributes in Data Shaper graph
  • DATA SHAPER DESIGNER
    • Configuration
      • Runtime configuration
        • Logging
        • Master Password
        • User Classpath
      • Data Shaper Server Integration
      • Execution monitoring
      • Java configuration
      • Engine configuration
      • Refresh Operation
    • Designer User Interface
      • Graph Editor with Palette of Components
      • Project Explorer Pane
      • Outline Pane
      • Tabs Pane
      • Execution Tab
      • Keyboard Shortcuts
    • Projects
      • Creating Data Shaper projects
      • Converting Data Shaper projects
      • Structure of Data Shaper projects
      • Versioning of server project content
      • Working with Data Shaper Server Projects
      • Project configuration
    • Graphs
      • Creating an empty graph
      • Creating a simple graph
        • Placing Components
        • Placing Components from Palette
        • Connecting Components with Edges
    • Execution
      • Successful Graph Execution
      • Run configuration
      • Connecting to a running job
      • Graph states
    • Common dialogs
      • URL file dialog
      • Edit Value dialog
      • Open Type dialog
    • Import
      • Import Data Shaper projects
      • Import from Data Shaper server sandbox
      • Import graphs
      • Import metadata
    • Export
      • Export graphs to HTML
      • Export to Data Shaper Server sandbox
      • Export image
      • Export Project as Library
    • Graph tracking
      • Changing record count font size
    • Search functionality
    • Working with Data Shaper server
      • Data Shaper server project basic principles
      • Connecting via HTTP
      • Connecting via HTTPS
      • Connecting via Proxy Server
    • Graph components
      • Adding components
      • Finding components
      • Edit component dialog box
      • Enable/disable component
      • Passing data through disabled component
      • Common properties of components
      • Specific attribute types
      • Metadata templates
    • Edges
      • Connecting Components with Edges
      • Types of Edges
      • Assigning Metadata to Edges
      • Colors of Edges
      • Debugging Edges
      • Edge Memory Allocation
    • Metadata
      • Records and Fields
        • Record Types
        • Data Types in Metadata
        • Data Formats
        • Locale and Locale Sensitivity
        • Time Zone
        • Autofilling Functions
      • Metadata Types
        • Internal Metadata
        • External (Shared) Metadata
        • SQL Query Metadata
        • Reading Metadata from Special Sources
      • Auto-propagated Metadata
        • Sources of Auto-Propagated Metadata
        • Explicitly Propagated Metadata
        • Priorities of Metadata
        • Propagation of SQL Query Metadata
      • Creating Metadata
        • Extracting Metadata from a Flat File
        • Extracting Metadata from an XLS(X) File
        • Extracting Metadata from a Database
        • Extracting Metadata from a DBase File
        • Extracting Metadata from Salesforce
        • SQL Query Metadata
        • User Defined Metadata
      • Merging Existing Metadata
      • Creating Database Table from Metadata and Database Connection
      • Metadata Editor
        • Opening Metadata Editor
        • Basics of Metadata Editor
        • Record Pane
        • Field Name vs. Label vs. Description
        • Details Pane
      • Changing and Defining Delimiters
      • Editing Metadata in the Source Code
      • Multi-value Fields
        • Lists and Maps Support in Components
        • Joining on multivalue fields (Comparison Rules)
    • Connections
      • Database Connections
        • Internal Database Connections
        • External (Shared) Database Connections
        • Database Connections Properties
        • Encryption of Access Password
        • Browsing Database and Extracting Metadata from Database Tables
        • Windows Authentication on Microsoft SQL Server
        • Snowflake Connection
        • Hive Connection
        • Troubleshooting
      • JMS Connections
      • QuickBase Connections
      • Hadoop Connections
      • Kafka Connections
      • OAuth2 Connections
      • MongoDB Connections
      • Salesforce Connections
    • Lookup Tables
      • Lookup Tables in Cluster Environment
      • Internal Lookup Tables
      • External (Shared) Lookup Tables
      • Types of Lookup Tables
    • Sequences
      • Persistent Sequences
      • Non Persistent Sequences
      • Internal Sequences
      • External (Shared) Sequences
      • Editing a Sequence
      • Sequences in Cluster Environment
    • Parameters
      • Internal Parameters
      • External (Shared) Parameters
      • Secure Graph Parameters
      • Graph Parameter Editor
      • Secure Graph Parameters
      • Parameters with CTL2 Expressions (Dynamic Parameters)
      • Environment Variables
      • Canonicalizing File Paths
      • Using Parameters
    • Internal/External Graph Elements
    • Dictionary
      • Creating a Dictionary
      • Using a Dictionary in Graphs
    • Execution Properties
    • Notes in Graphs
      • Placing Notes into Graph
      • Resizing Notes
      • Editing Notes
      • Formatted Text
      • Links from Notes
      • Folding Notes
      • Notes Properties
    • Transformations
      • Defining Transformations
      • Transform Editor
      • Common Java Interfaces
    • Data Partitioning (Parallel Running)
    • Data Partitioning in Cluster
      • High Availability
      • Scalability
      • Graph Allocation Examples
      • Example of Distributed Execution
      • Remote Edges
    • Readers
      • Common Properties of Readers
      • ComplexDataReader
      • DatabaseReader
      • DataGenerator
      • DataOneVFSReader
      • EDIFACTReader
      • FlatFileReader
      • JSONExtract
      • JSONReader
      • LDAPReader
      • MultiLevelReader
      • SpreadsheetDataReader
      • UniversalDataReader
      • X12Reader
      • XMLExtract
      • XMLReader
      • XMLXPathReader
    • Writers
      • Common Properties of Writers
      • DatabaseWriter
      • DataOneVFSWriter
      • EDIFACTWriter
      • FlatFileWriter
      • JSONWriter
      • LDAPWriter
      • SpreadsheetDataWriter
      • HIDDEN StructuredDataWriter
      • HIDDEN TableauWriter
      • Trash
      • UniversalDataWriter
      • X12Writer
      • XMLWriter
    • Transformers
      • Common Properties of Transformers
      • Aggregate
      • Concatenate
      • DataIntersection
      • DataSampler
      • Dedup
      • Denormalizer
      • ExtSort
      • FastSort
      • Filter
      • Map
      • Merge
      • MetaPivot
      • Normalizer
      • Partition
      • Pivot
      • Rollup
      • SimpleCopy
      • SimpleGather
      • SortWithinGroups
      • XSLTransformer
    • Joiners
      • Common Properties of Joiners
      • Combine
      • CrossJoin
      • DBJoin
      • ExtHashJoin
      • ExtMergeJoin
      • LookupJoin
      • RelationalJoin
    • Others
      • Common Properties of Others
      • CheckForeignKey
      • DBExecute
      • HTTPConnector
      • LookupTableReaderWriter
      • WebServiceClient
    • CTL2 - Data Shaper Transformation Language
    • Language Reference
      • Program Structure
      • Comments
      • Import
      • Data Types in CTL2
      • Literals
      • Variables
      • Dictionary in CTL2
      • Operators
      • Simple Statement and Block of Statements
      • Control Statements
      • Error Handling
      • Functions
      • Conditional Fail Expression
      • Accessing Data Records and Fields
      • Mapping
      • Parameters
      • Regular Expressions
    • CTL Debugging
      • Debug Perspective
      • Importing and Exporting Breakpoints
      • Inspecting Variables and Expressions
      • Examples
    • Functions Reference
      • Conversion Functions
      • Date Functions
      • Mathematical Functions
      • String Functions
      • Mapping Functions
      • Container Functions
      • Record Functions (Dynamic Field Access)
      • Miscellaneous Functions
      • Lookup Table Functions
      • Sequence Functions
      • Data Service HTTP Library Functions
      • Custom CTL Functions
      • CTL2 Appendix - List of National-specific Characters
      • HIDDEN Subgraph Functions
    • Tutorial
      • Creating a Transformation Graph
      • Filtering the records
      • Sorting the Records
      • Processing Speed-up with Parallelization
      • Debugging the Java Transformation
  • DATA SHAPER SERVER
    • Introduction
    • Administration
      • Monitoring
    • Using Graphs
      • Job Queue
      • Execution History
      • Job Inspector
    • Cluster
      • Sandboxes in Cluster
      • Troubleshooting
  • Install Data Shaper
    • Install Data Shaper
      • Introduction to Data Shaper installation process
      • Planning Data Shaper installation
      • Data Shaper System Requirements
      • Data Shaper Domain Master Configuration reference
      • Performing Data Shaper initial installation and master configuration
        • Creating database objects for PostgreSQL
        • Creating database objects for Oracle
        • Executing Data Shaper installer
        • Configuring additional firewall rules for Data Shaper
Powered by GitBook
On this page
  • Short Description
  • Ports
  • Metadata
  • Rollup Attributes
  • Details
  • CTL Interface
  • CTL Templates for Rollup
  • Access to input and output fields
  • Java Interface
  • Examples
  • Merging and updating incomplete records
  • Transforming multivalue fields to multiple records
  • Best Practices
  • See also
  1. DATA SHAPER DESIGNER
  2. Transformers

Rollup

Short Description

Rollup creates one or more output records from one or more input records.

Rollup receives potentially unsorted data through the single input port, transforms it and creates one or more output records from one or more input records.

The component can send different records to different output ports as specified by the user.

COMPONENT
SAME INPUT METADATA
SORTED INPUTS
INPUTS
OUTPUTS
JAVA
CTL
AUTO-PROPAGATED METADATA

Rollup

-

x

1

1-n

✓

✓

x

Ports

PORT TYPE
NUMBER
REQUIRED
DESCRIPTION
METADATA

Input

0

✓

For input data records

Any(In0)

Output

0

✓

For output data records

Any(Out0)

1-N

x

For output data records

Any(Out1-N)

Metadata

Rollup does not propagate metadata. Rollup has no metadata template. Input and output metadata fields can have any data types. Metadata on output ports can differ. You may need a metadata for the accumulator record in rollup transformation.

Rollup Attributes

ATTRIBUTE
REQ
DESCRIPTION
POSSIBLE VALUES

BASIC

Group Key

e.g.

Group accumulator

The ID of metadata that serves to create group accumulators. Metadata serves to store values used for transformation of individual groups of data records.

no metadata (default) | any metadata

Transform

[bl

Definition of the transformation written in the graph in CTL or Java.

Transform URL

[bl

The name of an external file, including the path, containing the definition of the transformation written in CTL or Java.

Transform class

[bl

The name of an external class defining the transformation.

Transform source charset

Encoding of external file defining the transformation. The default encoding depends on DEFAULT_SOURCE_CODE_CHARSET in defaultProperties.

E.g. UTF-8

Sorted input

By default, records are considered to be sorted. Either in ascending or descending order. Different fields may even have different sort order. If your records are not sorted, switch this attribute to false.

true (default) | false

Equal NULL

By default, records with null values of key fields are considered to be equal. If set to false, they are considered to be different from each other.

true (default) | false

[1] One of these must specified.

Details

Rollup requires transformation. You can define the transformation using CTL (see CTL interface below) or Java (see Java Interface below).

The flow of function calls in a rollup transformation is depicted below. If any optional function (except functions for error handling) is not used, the position of unimplemented function from diagram is skipped.

If you do not define Group accumulator metadata, VoidMetadata is used in transformation functions.

CTL Interface

The transformation uses a CTL template for Rollup, implement a RecordRollup interface or inherit from a DataRecordRollup superclass. Below is a list of RecordRollup interface methods. For detailed information about this interface, see Java Interface below.

Once you have written your transformation, you can also convert it to Java language code by clicking a corresponding button at the upper right corner of the tab.

You can open the transformation definition as another tab of the graph (in addition to the Graph and Source tabs of Graph Editor) by clicking a corresponding button at the upper right corner of the tab.

CTL Templates for Rollup

CTL TEMPLATE FUNCTIONS

void init()

Required

No

Description

Initializes the component, setup the environment and global variables

Invocation

Called before processing the first record

Returns

void

CTL TEMPLATE FUNCTIONS
void initGroup(<metadata name> groupAccumulator)

Required

Yes

Input Parameters

groupAccumulator (metadata specified by the user)

Returns

void

Invocation

Called repeatedly, once for the first input record of each group. Called before updateGroup(groupAccumulator).

Description

Initializes information for specific group

Example

See here below

function void initGroup(
      companyCustomers groupAccumulator) {
   groupAccumulator.count = 0;
   groupAccumulator.totalFreight = 0;
}
CTL TEMPLATE FUNCTIONS
boolean updateGroup(<metadata name> groupAccumulator)

Required

Yes

Input Parameters

groupAccumulator (metadata specified by user) If groupAccumulator is not defined, VoidMetadata Accumulator is used in the function signature.

Returns

false (updateTransform(counter,groupAccumulator) is not called) true (updateTransform(counter,groupAccumulator) is called)

Invocation

Called repeatedly (once for each input record of the group, including the first and the last record). Called after the initGroup(groupAccumulator) function has already been called for the whole group.

Description

Updates information for specific group. If updateGroup() fails and user has not defined any updateGroupOnError(), the whole graph will fail. If any of the input records causes a failure of the updateGroup() function and if user has defined another function (updateGroupOnError()), processing continues in this updateGroupOnError() at the place where updateGroup() failed. The updateGroup() passes to the updateGroupOnError() error message and stack trace as arguments.

Example

See here below

function boolean updateGroup(companyCustomers groupAccumulator) {
   groupAccumulator.count++;
   groupAccumulator.totalFreight = groupAccumulator.totalFreight + $in.0.Freight;
   return true;
}
CTL TEMPLATE FUNCTIONS
boolean finishGroup(<metadata name> groupAccumulator)

Required

Yes

Input Parameters

groupAccumulator (metadata specified by user) If groupAccumulator is not defined, VoidMetadata Accumulator is used in the function signature.

Returns

true(transform(counter,groupAccumulator) is called) false (transform(counter,groupAccumulator) is not called)

Invocation

Called repeatedly, once for the last input record of each group. Called after updateGroup(groupAccumulator) has already been called for all input records of the group.

Description

Finalizes the group information. If finishGroup() fails and no finishGroupOn Error() is defined, the whole graph will fail. If any of the input records causes fail of the finishGroup() function, and the finishGroupOn Error() function is defined, processing continues in the finishGroupOn Error() at the place where finishGroup() failed. The finishGroup() passes to the finishGroupOn Error() error message and stack trace as arguments.

Example

See here below

function boolean finishGroup(companyCustomers groupAccumulator) {
   groupAccumulator.avgFreight = groupAccumulator.totalFreight / groupAccumulator.count;
   return true;
}
CTL TEMPLATE FUNCTIONS
integer updateTransform(integer counter, <metadata name> groupAccumulator)

Required

Yes

Input Parameters

integer counter (starts from 0, specifies the number of created records. should be terminated as shown in the example below. Function calls end when SKIP is returned.) <metadata name> groupAccumulator (metadata specified by the user) If groupAccumulator is not defined, VoidMetadata Accumulator is used in the function signature.

Returns

Invocation

Called repeatedly as specified by user. Called after updateGroup(groupAccumulator) returns true. The function is called until SKIPis returned.

Description

It creates output records based on individual record information. If updateTransform() fails and no updateTransformOnError() is defined, the whole graph will fail. If any part of the transform() function for some output record causes fail of the updateTransform() function, and if another (updateTransformOnError()) is defined, processing continues in this updateTransformOnError() at the place where updateTransform() failed. The updateTransformOnError() function gets the information gathered by updateTransform() that was get from previously successfully processed code. The error message and stack trace are passed to updateTransformOnError(), as well.

Example

See here below

function integer updateTransform(integer counter, companyCustomers groupAccumulator) {
   if (counter >= Length) {
      clear(customers);
      return SKIP;
   }
   $out.0.customers = customers[counter];
   $out.0.EmployeeID = $in.0.EmployeeID;
   return ALL;
}
CTL TEMPLATE FUNCTIONS
integer transform(integer counter, <metadata name> groupAccumulator)

Required

Yes

Input Parameters

integer counter (starts from 0, specifies the number of created records. should be terminated as shown in example below. Function calls end when SKIP is returned.) <metadata name> groupAccumulator (metadata specified by the user) If groupAccumulator is not defined, VoidMetadata Accumulator is used in the function signature.

Returns

Invocation

Called repeatedly as specified by the user. Called after finishGroup(groupAccumulator) returns true. The function is called until SKIP is returned.

Description

It creates output records based on all of the records of the whole group. If transform fails and no transformOnError() is defined, the whole graph will fail. If any part of the transform() function for some output record causes fail of the transform() function, and if another (TransformOnError()) is defined, processing continues in this TransformOnError() at the place where transform() failed. The transformOnError() function gets the information gathered by transform() that was get from previously successfully processed code. The error message and stack trace are passed to transformOnError(), as well.

Example

See here below

function integer transform(integer counter, companyCustomers groupAccumulator) {
   if (counter > 0) return SKIP;
   $out.0.ShipCountry = $in.0.ShipCountry;
   $out.0.Count = groupAccumulator.count;
   $out.0.AvgFreight = groupAccumulator.avgFreight;
   return ALL
}
CTL TEMPLATE FUNCTIONS
void initGroupOnError(string errorMessage, string stackTrace, <metadata name> groupAccumulator)

Required

No

Input parameters

string errorMessage string stackTrace groupAccumulator (metadata specified by user) If groupAccumulator is not defined, VoidMetadata Accumulator is used in the function signature.

Returns

Void

Invocation

Called if initGroup() throws an exception.

Description

Initializes information for specific group.

Example

See here below.

function void initGroupOnError(
        string errorMessage,
        string stackTrace,
        companyCustomers groupAccumulator)
   printErr(errorMessage);
}
CTL TEMPLATE FUNCTIONS
boolean updateGroupOnError(string errorMessage, string stackTrace, <metadata name> groupAccumulator)

Required

No

Input Parameters

string errorMessage string stackTrace groupAccumulator (metadata specified by user) If groupAccumulator is not defined, VoidMetadata Accumulator is used in the function signature.

Returns

false (updateTransform(counter,groupAccumulator) is not called) true (updateTransform(counter,groupAccumulator) is called)

Invocation

Called if updateGroup() throws an exception for a record of the group.

Description

Updates information for specific group.

Example

See here below.

function boolean updateGroupOnError(string errorMessage, string stackTrace, companyCustomers groupAccumulator) {
   printErr(errorMessage);
   return true;
}
CTL TEMPLATE FUNCTIONS
boolean finishGroupOnError(string errorMessage, string stackTrace, <metadata name> groupAccumulator)

Required

No

Input Parameters

string errorMessage string stackTrace groupAccumulator (metadata specified by user) If groupAccumulator is not defined, VoidMetadata Accumulator is used in the function signature.

Returns

true (transform(counter,groupAccumulator) is called) false (transform(counter,groupAccumulator) is not called)

Invocation

Called if finishGroup() throws an exception.

Description

Finalizes the group information.

Example

See here below.

function boolean finishGroupOnError(string errorMessage, string stackTrace, <metadata name> groupAccumulator) {
   printErr(errorMessage);
   return true;
}
CTL TEMPLATE FUNCTIONS
integer updateTransformOnError(string errorMessage, string stackTrace, integer counter, <metadata name> groupAccumulator)

Required

Yes

Input Parameters

string errorMessage string stackTrace integer counter (starts from 0, specifies the number of created records. should be terminated as shown in the example below. The function calls end when SKIP is returned.) groupAccumulator (metadata specified by user) If groupAccumulator is not defined, VoidMetadata Accumulator is used in the function signature.

Returns

Invocation

Called if updateTransform() throws an exception.

Description

It creates output records based on individual record information.

Example

See here below.

function integer updateTransformOnError(string errorMessage, string stackTrace, integer counter, companyCustomers groupAccumulator) {
   if (counter >= 0) {
      return SKIP;
   }
   printErr(errorMessage);
   return ALL;
}

CTL TEMPLATE FUNCTIONS

integer transformOnError(string errorMessage, string stackTrace, integer counter, groupAccumulator)

Required

No

Input Parameters

string errorMessage string stackTrace integer counter (starts from 0, specifies the number of created records. should be terminated as shown in the example below. The function calls end when SKIP is returned.) groupAccumulator (metadata specified by user) If groupAccumulator is not defined, VoidMetadata Accumulator is used in the function signature.

Returns

Invocation

Called if transform() throws an exception.

Description

It creates output records based on all of the records of the whole group.

Example

See here below.

function integer transformOnError(string errorMessage, string stackTrace, integer counter, companyCustomers groupAccumulator) {
   if (counter >= 0) {
      return SKIP;
   }
   printErr(errorMessage);
   return ALL;
}
CTL TEMPLATE FUNCTIONS
string getMessage()

Required

No

Description

Prints an error message specified and invoked by the user.

Invocation

Called in any time specified by the user (called only when either updateTransform(), transform(), updateTransformOnError() or TransformOnError() returns value less than or equal to -2).

Returns

string

CTL TEMPLATE FUNCTIONS
void preExecute()

Required

No

Input parameters

None

Returns

void

Description

May be used to allocate and initialize resources required by the transform. All resources allocated within this function should be released by the postExecute() function.

Invocation

Called during each graph run before the transform is executed.

CTL TEMPLATE FUNCTIONS
void postExecute()

Required

No

Input parameters

None

Returns

void

Description

Should be used to free any resources allocated within the preExecute() function.

Invocation

Called during each graph run after the entire transform was executed.

Access to input and output fields

All of the other CTL template functions allow to access neither inputs nor outputs or groupAccumulator.

Input records or fields Input records or fields are accessible within the initGroup(), updateGroup(), finishGroup(), initGroupOnError(), updateGroupOnError() and finishGroupOnError() functions.

They are also accessible within the updateTransform(), transform(), updateTansformOnError() and transformOnError() functions.

Output records or fields Output records or fields are accessible within the updateTransform(), transform(), updateTansformOnError() and transformOnError() functions.

Group accumulator Group accumulator is accessible within the initGroup(), updateGroup(), finishGroup(), initGroupOnError(), updateGroupOnError() and finishGroupOnError() functions.

It is also accessible within the updateTransform(), transform(), updateTansformOnError() and transformOnError() functions.

Warning: Remember that if you do not hold these rules, NPE will be thrown.

Java Interface

  • void init(Properties parameters, DataRecordMetadata inputMetadata, DataRecordMetadata accumulatorMetadata, DataRecordMetadata[] outputMetadata) Initializes the rollup transform. This method is called only once at the beginning of the life-cycle of the rollup transform. Any internal allocation/initialization code should be placed here.

  • void initGroup(DataRecord inputRecord, DataRecord groupAccumulator) This method is called for the first data record in a group. Any initialization of the group accumulator should be placed here.

  • void initGroupOnError(Exception exception, DataRecord inputRecord, DataRecord groupAccumulator) This method is called for the first data record in a group. Any initialization of the group "accumulator" should be placed here. Called only if initGroup(DataRecord, DataRecord) throws an exception.

  • boolean updateGroup(DataRecord inputRecord, DataRecord groupAccumulator) This method is called for each data record (including the first one as well as the last one) in a group in order to update the group accumulator.

  • boolean updateGroupOnError(Exception exception, DataRecord inputRecord, DataRecord groupAccumulator) This method is called for each data record (including the first one as well as the last one) in a group in order to update the group accumulator. Called only if updateGroup(DataRecord, DataRecord) throws an exception.

  • boolean finishGroup(DataRecord inputRecord, DataRecord groupAccumulator) This method is called for the last data record in a group in order to finish the group processing.

  • boolean finishGroupOnError(Exception exception, DataRecord inputRecord, DataRecord groupAccumulator) This method is called for the last data record in a group in order to finish the group processing. Called only if finishGroup(DataRecord, DataRecord) throws an exception.

  • int updateTransformOnError(Exception exception, int counter, DataRecord inputRecord, DataRecord groupAccumulator, DataRecord[] outputRecords) This method is used to generate output data records based on the input data record and the contents of the group accumulator (if it was requested). Called only if updateTransform(int, DataRecord, DataRecord) throws an exception.

  • int transformOnError(Exception exception, int counter, DataRecord inputRecord, DataRecord groupAccumulator, DataRecord[] outputRecords) This method is used to generate output data records based on the input data record and the contents of the group accumulator (if it was requested). Called only if transform(int, DataRecord, DataRecord) throws an exception.

Examples

Merging and updating incomplete records

You have a list of records containing name, email address and phone number. Records do not have all fields filled in. Records are sorted according to the field name.

Merge together data of records with the same name. If more records with the same name have the same field filled in, use the last one.

Alice|alice@example.com|
Alice|                 |+420123456789
Alice|alice@example.org|
Bob  |                 |+421212345678
Bob  |bob@example.info |
Eve  |eve@example.com  |+420720123456
Eve  |                 |+420720123457

Solution Input and output metadata (updateRecord) have fields name, email and phoneNumber.

Use the attributes Group key, Group accumulator and Transform of Rollup.

ATTRIBUTE
VALUE

Group Key

Name

Group accumulator

updateRecord

Transform

See the code below

//#CTL2

function void initGroup(updateRecord groupAccumulator) {
 	groupAccumulator.* = $in.0.*;
 	return;
}

function boolean updateGroup(updateRecord groupAccumulator) {
 	if (!isnull($in.0.email))
 	{
 	 	groupAccumulator.email = $in.0.email;
 	}

 	if (!isnull($in.0.phoneNumber))
 	{
 	 	groupAccumulator.phoneNumber = $in.0.phoneNumber;
 	}

 	return false;
}

function boolean finishGroup(updateRecord groupAccumulator) {
 	return true;
}

function integer updateTransform(integer counter, updateRecord groupAccumulator) {
 	raiseError("Function not implemented!");
}

function integer transform(integer counter, updateRecord groupAccumulator) {
 	if ( counter > 0 )
 	{
 	 	return SKIP;
 	}

 	$out.0.* = groupAccumulator.*;
 	return ALL;
}

Result records contains merged field values:

Alice|alice@example.org|+420123456789
Bob  |bob@example.info |+421212345678
Eve  |eve@example.com  |+420720123457

Transforming multivalue fields to multiple records

Input records containing name, group and email have a multivalue field email. Split input stream to two data streams: one with name and group, the other one with name and email. The output records will be loaded into a database without support of multivalue fields.

Jane Green |users |[jane.green@example.org, greenj@example.org, jane.brown@example.org]
John Smith |users |[john.smith@example.com, jsmith@example.com]
Peter Green|users |[peter.green@example.com]

The field name of an input record is unique.

Solution Input metadata users has fields name, group and email. Output metadata users2 has fields name and group, output metadata emails has fields name and email.

Use the Rollup attributes Group key, Group accumulator and Transform.

ATTRIBUTE
VALUE

Group key

name

Group accumulator

users

Transform

See the code below

//#CTL2

function void initGroup(users groupAccumulator) {
 	return;
}

function boolean updateGroup(users groupAccumulator) {
 	groupAccumulator.* = $in.0.*;
 	return true;
}

function boolean finishGroup(users groupAccumulator) {
 	return true;
}

function integer updateTransform(integer counter, users groupAccumulator) {
 	if(counter >= length(groupAccumulator.email )) {
 	 	return SKIP;
 	}
 	$out.1.name = $in.0.name;
 	$out.1.email = groupAccumulator.email[counter];
 	return 1;
}

function integer transform(integer counter, users groupAccumulator) {
 	if(counter > 0 )
 	{
 	 	return SKIP;
 	}
 	$out.0.name = $in.0.name;
 	$out.0.group = $in.0.group;
 	return 0;
}

The transformation above requires the field user to be unique.

You receive 3 records on the first output port:

Jane Green |users
John Smith |users
Peter Green|users

Six records will be send to second output port:

Jane Green |jane.green@example.org
Jane Green |greenj@example.org
Jane Green |jane.brown@example.org
John Smith |john.smith@example.com
John Smith |jsmith@example.com
Peter Green|peter.green@example.com

Best Practices

To process a large number of records, sort records first and than use Rollup instead of using Rollup with the Sorted input attribute set to false.

If the transformation is specified in an external file (with Transform URL), we recommend users to explicitly specify Transform source charset.

See also

PreviousPivotNextSimpleCopy

Last updated 1 month ago

Key according to which the records are considered to be included into one group. Expressed as a sequence of individual input field names separated from each other by a semicolon. For more information, see . If not specified, all records are considered to be members of a single group.

Integer numbers. For more information, see .

Integer numbers. For more information, see .

Integer numbers. For detailed information, see .

Integer numbers. For detailed information, see .

The transformation implements methods of the RecordRollup interface and inherits other common methods from the Transform interface. See . Following is the list of the RecordRollup interface methods:

int updateTransform(int counter, DataRecord inputRecord, DataRecord groupAccumulator, DataRecord[] outputRecords) This method is used to generate output data records based on the input data record and the contents of the group accumulator (if it was requested). The output data record will be sent to the output when this method finishes. This method is called whenever the boolean updateGroup(DataRecord, DataRecord) method returns true. The counter argument is the number of previous calls to this method for the current group update. See for detailed information about return values and their meaning.

int transform(int counter, DataRecord inputRecord, DataRecord groupAccumulator, DataRecord[] outputRecords) This method is used to generate output data records based on the input data record and the contents of the group accumulator (if it was requested). The output data record will be sent to the output when this method finishes. This method is called whenever the boolean finishGroup(DataRecord, DataRecord) method returns true. The counter argument is the number of previous calls to this method for the current group. See for detailed information about return values and their meaning.

Common Java Interfaces
Return Values of Transformations
Return Values of Transformations
Denormalizer
Normalizer
Common Properties of Components
Specific attribute types
Common Properties of Transformers
Group Key
Return Values of Transformations
Return Values of Transformations
Return Values of Transformations
Return Values of Transformations