DSQLマップでループを分割
複数のループを1つのループにマッピングします。
始める前に
- 入力と出力のストラクチャーが作成済みであること。ストラクチャーの作成には下のJSONサンプルを使用できます。
このタスクについて
{
"bicycles": [
{
"make": "MBIKE",
"description": "27.5 inch electric mountain bike",
"color": "blue",
"price": 899.99
},
{
"make": "EBIKE",
"description": "Electric hybrid bike",
"color": "grey/green",
"price": 999.99
},
{
"make": "WBIKE",
"description": "Women's road bike",
"color": "white",
"price": 299.99
}
],
"scooters": [
{
"make": "ESCOOT",
"description": "Camou electric scooter",
"color": "black",
"price": 749
},
{
"make": "EVSCOOT",
"description": "Folding electric velocity+ scooter",
"color": "black",
"price": 599.99
},
{
"make": "KSCOOT",
"description": "24 volt kid scooter",
"color": "white",
"price": 299.99
}
]
}
出力ストラクチャーは次のようになります。
{
"items": [
{
"make": "",
"description": "",
"price": ""
}
]
}
手順
タスクの結果
{
"items":[
{
"make":"MBIKE",
"description":"27.5 inch electric mountain bike",
"price":"899.99"
},
{
"make":"EBIKE",
"description":"Electric hybrid bike",
"price":"999.99"
},
{
"make":"WBIKE",
"description":"Women's road bike",
"price":"299.99"
},
{
"make":"ESCOOT",
"description":"Camou electric scooter",
"price":"749.0"
},
{
"make":"EVSCOOT",
"description":"Folding electric velocity+ scooter",
"price":"599.99"
},
{
"make":"KSCOOT",
"description":"24 volt kid scooter",
"price":"299.99"
}
]
}
また、[DSQL Script] (DSQL スクリプト)ビューで、UNION ALL句を使ったData Shaping Query Languageでどのように処理されるかを確認することもできます。詳細は、TalendData Shaping Languageリファレンスガイドをご覧ください。この例では、次のスクリプトが生成されます。
FROM itemsbycategory
SELECT {
items = (
FROM bicycles
SELECT {
make = make,
description = description,
price = price
}
UNION ALL
FROM scooters
SELECT {
make = make,
description = description,
price = price
}
)
}