How to use DENORMALIZER to achieve the following
source.txt
group2,A
group2,B
group2,C
group1,A
group1,B
target.txt
group2,A,B,C
group1,A,B,
In the 2.6 version I did not test successfully.Please give a sample to achieve
source.txt
group2,A
group2,B
group2,C
group1,A
group1,B
target.txt
group2,A,B,C
group1,A,B,
In the 2.6 version I did not test successfully.Please give a sample to achieve
-
//#TL
// This transformation defines the way in which multiple input records
// (with the same key) are denormalized into one output record.
string result;
// This function is called for each input record in a group of records with
// the same key.
function append() {
result = concat(result, $field2,',');
}
// This function is called once after the append() function was called for all records
// in a record group defined by the key. It creates an output record for the record group.
function transform() {
$field1 := $field1;
$field2 := substring(result,0,length(result) - 1);
}
// Called during component initialization.
// function init() {}
// Called after the output record was created in the transform() function.
function clean() {
result='';
} -
Syntax
string concat(type arg1, type arg2, …);
Thank you for your reply, concat can return string type,
if I want to return to other types it.
I think the data should not be passed concat to store,
should be resolved through java.util.Map and java.util.Vector to store, but did not materialize.
source fmt
<?xml version="1.0" encoding="utf-8"?>
<Record name="" type="delimited">
<Field name="Field0" type="string" format="" nullable="true" default="0" size="100" length="100" scale="0" delimiter=","/>
<Field name="Field1" type="string" format="" nullable="true" default="0" size="100" length="100" scale="0" delimiter="\n"/>
</Record>
target fmt
<?xml version="1.0" encoding="utf-8"?>
<Record name="" type="delimited">
<Field name="Field00" type="string" format="" nullable="true" default="0" size="100" length="100" scale="0" delimiter=","/>
<Field name="Field11" type="string" format="" nullable="true" default="0" size="100" length="100" scale="0" delimiter=","/>
<Field name="Field22" type="string" format="" nullable="true" default="0" size="100" length="100" scale="0" delimiter=","/>
<Field name="Field33" type="string" format="" nullable="true" default="0" size="100" length="100" scale="0" delimiter="\n"/>
</Record>
How to achieve output Record is more than the case of Field -
In time being hierarchical fields are not supported by Clover. -
This feature can be referred to the development plan? Transpose the ranks of the basic functions is to output ports output multi-column fields. :D
Please sign in to leave a comment.
Comments 4