title: How to relationalize a JSON to flat structure in AWS Glue
body: <p>Trying to flatten input JSON data having two map/dictionary fields (custom_event1 and custom_event2), which may contain any key-value pair data. In order to create an output table from the data frame, will have to avoid the flattening of custom_events and store it as JSON string in the column.</p>
  
  <p>Following <a href="https://aws.amazon.com/blogs/big-data/simplify-querying-nested-json-with-the-aws-glue-relationalize-transform/" rel="nofollow noreferrer">this</a> doc, Relationalize.apply is flattening the custom_events map also.</p>
  
  <pre><code>Sample JSON:
  
  {
      "id": "sklfsdfskdlfsdfsdfkhsdfssdf",
      "idtype": "cookieId",
      "event": "install",
      "sub_event": null,
      "ip": "XXXXXX",
      "geo": {
          "country": "IN",
          "city": null,
          "region": null
      },
      "carrier": {
          "operator": null,
          "network": null,
          "connection_type": null
      },
      "user_agent": "Mozilla/5.0",
      "device": {
          "brand": "LYF",
          "model": null,
          "type": null
      },
      "package": {
          "pkgName": "XXXXXXXX",
          "pkgVersion": "1.5.6.3",
          "pkgRating": null,
          "timestamp": "2017-12-14 11:51:27"
      },
      "custom_event1": {
          "key1": "value1",
          "key2": "value2"
      },
      "custom_event2": {
          "key": "value"
      }
  }
  </code></pre>
  
  <p>How to store JSON data with a dynamic map field in a Relational storage?</p>