スコアの集計 - Cloud - 8.0

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

Version
Cloud
8.0
Language
日本語
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
ジョブデザインと開発 > ジョブデザイン
Last publication date
2024-02-22

スコアを集計するtAggregateRowコンポーネントを追加するには、以下のようにします:

手順

  1. tUniteコンポーネントの次に、新しいtAggregateRowコンポーネントを追加します。
    addComponent {
    	setComponentDefinition {
    		TYPE: "tAggregateRow",
    		NAME: "tAggregateRow_1",
    		POSITION: 512, 192
    	}
    
    }
  2. tAggregateRowsetComponentDefinition {}の後に、setSettings {}関数を使ってコンポーネントのプロパティを定義します。

    この例では、aggregateのラベルが付いたtAggregateRowコンポーネントが、sumavgmaxminの各計算を実行し、各subjectの総合得点、平均点、最高点、最低点を取得します。

    	setSettings {
    		GROUPBYS {
    			OUTPUT_COLUMN : "subject",
    			INPUT_COLUMN : "subject"
    		},
    		OPERATIONS {
    			OUTPUT_COLUMN : "sum",
    			FUNCTION : "sum",
    			INPUT_COLUMN : "score",
    			OUTPUT_COLUMN : "average",
    			FUNCTION : "avg",
    			INPUT_COLUMN : "score",
    			OUTPUT_COLUMN : "max",
    			FUNCTION : "max",
    			INPUT_COLUMN : "score",
    			OUTPUT_COLUMN : "min",
    			FUNCTION : "min",
    			INPUT_COLUMN : "score"
    		},
    		LABEL : "aggregate"
    	}
  3. setSettings {}の次に、addSchema {}関数を入力して、コンポーネントの出力構造を定義します。

    この例では、tAggregateRowコンポーネントは次の5つのカラムを出力します。

    • subject、文字列型
    • sum: 各教科の総合得点、倍精度型
    • average: 各教科の平均点、倍精度型
    • max: 各教科の最高点、倍精度型
    • min: 各教科の最低点、倍精度型
    	addSchema {
    		NAME: "tAggregateRow_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
    		}
    	}