MetaPivot
Short Description
MetaPivot converts every incoming record into several output records, each one representing a single field from the input.
COMPONENT | SAME INPUT METADATA | SORTED INPUTS | INPUTS | OUTPUTS | JAVA | CTL | AUTO-PROPAGATED METADATA |
---|---|---|---|---|---|---|---|
MetaPivot | - | x | 1 | 1 | x | x | ✓ |
Ports
PORT TYPE | NUMBER | REQUIRED | DESCRIPTION | METADATA |
---|---|---|---|---|
Input | 0 | ✓ | For input data records | Any1 |
Output | 0 | ✓ | For transformed data records | Any2 |
Metadata
MetaPivot does not propagate metadata.
MetaPivot has a metadata template on its output port.
When working with MetaPivot, you have to use a fixed format of the output metadata. The metadata fields represent particular data types. Field names and data types have to be set exactly as follows (otherwise unexpectedBadDataFormatException
will occur):
FIELD NAME | TYPE | DESCRIPTION |
---|---|---|
recordNo | long | The serial number of a record (outputs can be later grouped by this) - fields of the same record share the same number. |
fieldNo | integer | The serial number of a record (outputs can be later grouped by this) - fields of the same record share the same number. |
fieldName | string | The name of the field as it appears on the input |
fieldType | string | The field type, e.g. string, date, decimal |
valueBoolean | boolean | The boolean value of the field. |
valueByte | byte | The byte value of the field. |
valueDate | date | The date value of the field. |
valueDecimal | decimal | The decimal value of the field. |
valueInteger | integer | The integer value of the field. |
valueLong | long | The long value of the field. |
valueNumber | number | The number value of the field. |
valueString | string | The string value of the field. |
MetaPivot Attributes
MetaPivot has no transformation-affecting attributes.
Details
On its single input port, MetaPivot receives data that does not have to be sorted. Each field of the input record is written as a new line on the output. The metadata represents data types and is restricted to a fixed format. All in all, MetaPivot can be used to effectively transform your records to a neat data-dependent structure.
Unlike Normalizer , which MetaPivot is derived from, no transformation is defined. MetaPivot always does the same transformation: it takes the input records and rotates them from input columns to output rows.
The total number of output records produced by MetaPivot equals to (number of input records) * (number of input fields).
Some of the fields only make the output look better arranged. These can be omitted if required. The fields that do not have to be included in the output metadata are: recordNo, fieldNo
and fieldType
.
Examples
Converting Line to List
Convert records with metadata fields username, surname
and first name
.
doejohn|Doe |John
smithel|Smith|Elisabeth
...
into lines having each field value on a separate line:
username |doejohn
surname |John
firstname|Doe
username |smithel
surname |Elisabeth
firstname|Smith
...
Solution
Place the component into a graph and connect edges. The component does not need to be set up.
Note: You need Map to exclude unnecessary output fields.
See also
Pivot
Common Properties of Components
Specific attribute types
Common Properties of Transformers
Updated about 1 year ago