Sorting the aggregated scores - Cloud - 8.0

Talend Job Script Reference Guide

Version
Cloud
8.0
Language
English
Product
Talend Big Data
Talend Big Data Platform
Talend Cloud
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Real-Time Big Data Platform
Module
Talend CommandLine
Talend Studio
Content
Design and Development > Designing Jobs
Last publication date
2024-02-22

The following procedure will add and configure a tSortRow component to sort the aggregation result.

Procedure

  1. Next to the tAggregateRow component, add a new component, tSortRow.
    addComponent {
    	setComponentDefinition {
    		TYPE: "tSortRow",
    		NAME: "tSortRow_1",
    		POSITION: 672, 192
    	}
    
    }
  2. Next to the setComponentDefinition {} of tSortRow, define the component properties using the setSettings {} function.

    This example will rearrange the aggregation result by sorting the total scores in the descending numerical order.

    	setSettings {
    		CRITERIA {
    			COLNAME : "sum",
    			SORT : "num",
    			ORDER : "desc"
    		},
    		LABEL : "sort"
    	}
  3. Next to the setSettings {}, enter the addSchema {} function to define the output structure of the component.

    In this example, the tSortRow component must have the same schema structure of the tAggregateRow component.

    	addSchema {
    		NAME: "tSortRow_1",
    		CONNECTOR: "FLOW"
    		addColumn {
    			NAME: "subject",
    			TYPE: "id_String"
    		}
    		addColumn {
    			NAME: "sum",
    			TYPE: "id_Double",
    			PRECISION: 2
    		}
    		addColumn {
    			NAME: "average",
    			TYPE: "id_Double",
    			PRECISION: 2
    		}
    		addColumn {
    			NAME: "max",
    			TYPE: "id_Double",
    			PRECISION: 2
    		}
    		addColumn {
    			NAME: "min",
    			TYPE: "id_Double",
    			PRECISION: 2
    		}
    	}