グルーピングエレメント
		 Data Shaping Query LanguageのGROUP BY句とGROUP AS句を使い、フラットファイルから階層を作成します。
    
        始める前に
- 入力と出力のストラクチャーが作成済みであること。ストラクチャーの作成には下のJSONサンプルを使用できます。
 
このタスクについて
この例では、フラットなJSONファイルから店舗に関するデータを抽出して階層ストラクチャーに書き込むDSQLマップを作成します。
以下のサンプルJSONでは、items配列の各オブジェクトに、項目に関するデータ(店舗や部署など)が含まれています。出力では、項目ごとのレコードではなく、まず店舗ごとのレコード、次に各店舗の部署ごとのレコード、最後に各部署でのオブジェクトごとのレコードを持つようにしたいと考えています。
入力データは次のようになります。
{
    "items": [
        {
            "store_name": "plusstore",
            "store_location": "saint louis",
            "department_name": "sports",
            "salesperson_id": "25",
            "item_name": "MBIKE"
        },
        {
            "store_name": "plusstore",
            "store_location": "saint louis",
            "department_name": "sports",
            "salesperson_id": "25",
            "item_name": "ESCOOT"
        },
        {
            "store_name": "plusstore",
            "store_location": "saint louis",
            "department_name": "electronics",
            "salesperson_id": "32",
            "item_name": "Portable SSD T5"
        },
        {
            "store_name": "plusstore",
            "store_location": "saint louis",
            "department_name": "electronics",
            "salesperson_id": "32",
            "item_name": "Extreme Portable SSD"
        },
        {
            "store_name": "goodstore",
            "store_location": "nashville",
            "department_name": "electronics",
            "salesperson_id": "47",
            "item_name": "Toshiba P300"
        },
        {
            "store_name": "goodstore",
            "store_location": "nashville",
            "department_name": "fresh",
            "salesperson_id": "47",
            "item_name": "Italian tomatoes"
        }
    ]
}出力ストラクチャーは次のようになります。
{
    "stores": [
        {
            "name": "",
            "location": "",
            "departments": [
                {
                    "name": "",
                    "salesperson_id": "",
                    "items": [
                        {
                            "name": ""
                        }
                    ]
                }
            ]
        }
    ]
}手順
タスクの結果
{
   "stores":[
      {
         "name":"plusstore",
         "location":"saint louis",
         "departments":[
            {
               "name":"electronics",
               "salesperson_id":"32",
               "items":[
                  {
                     "name":"Portable SSD T5"
                  },
                  {
                     "name":"Extreme Portable SSD"
                  }
               ]
            },
            {
               "name":"sports",
               "salesperson_id":"25",
               "items":[
                  {
                     "name":"MBIKE"
                  },
                  {
                     "name":"ESCOOT"
                  }
               ]
            }
         ]
      },
      {
         "name":"goodstore",
         "location":"nashville",
         "departments":[
            {
               "name":"electronics",
               "salesperson_id":"47",
               "items":[
                  {
                     "name":"Toshiba P300"
                  }
               ]
            },
            {
               "name":"fresh",
               "salesperson_id":"47",
               "items":[
                  {
                     "name":"Italian tomatoes"
                  }
               ]
            }
         ]
      }
   ]
}