Time for action – calculating the top scores with a subtransformation
Let's modify the transformation that calculates the top scores to avoid unnecessary duplication of steps:
Under the
transformation
folder, create a new folder namedsubtransformations
.Create a new transformation and save it in that new folder with the name
scores.ktr
.Expand the Mapping category of steps. Select a Mapping input specification step and drag it to the work area.
Double-click the step and fill it like this:
Add a Sort rows step and use it to sort the
score
field in descending order.Add a JavaScript step and type the following code to filter the top 10 rows:
trans_Status = CONTINUE_TRANSFORMATION; if (getProcessCount('r')>10) trans_Status = SKIP_TRANSFORMATION;
Add an Add sequence step to add a sequence field named
seq
.Finally, add a Mapping output specification step. You will find it in the Mapping category of steps. Your transformation looks like this:
Save the transformation.
Open the transformation
top_scores...