Sorting the aggregated scores - 6.5

Talendジョブスクリプトリファレンス

author
Talend Documentation Team
EnrichVersion
6.5
EnrichProdName
Talend Big Data
Talend Big Data Platform
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
task
ジョブデザインと開発 > ジョブデザイン
EnrichPlatform
Talend CommandLine
Talend Studio

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
    		}
    	}