DynamoDB Qualifier Examples for Parsing Formulas

This example shows a simple formula to concatenate two text values. The value of the location virtual attribute is evaluated using the values of city and state attributes. For example, if city is Los Angeles and state is California, location value is defined as Los Angeles, California.

{
  "columns": {
    "city": {
      "presence": "any",
      "type": "S",
      "values": [{
        "definition": "LEFT(location, FIND(",", location)-1)"
      }]
    },
    "state": {
      "presence": "any",
      "type": "S",
      "values": [{
        "definition": "MID(location, FIND(", ", location)+2, LEN(location))"
      }]
    },
    "location": {
      "virtual": "true",
      "values": [{
        "definition": "city+", "+state"
      }]
    }
  }
}

This example depicts use of parsing formulas to decode an address stored in a single attribute in Amazon DynamoDB. The data field captures the street address as country#region#city#address for querying purposes. For example, USA#MI#Ann Arbor#707 Oxford Rd.

{
  "columns": {
    "pk": {
      "filter": "suppliers#%",
      "values": [
        {
          "definition": ""suppliers#" +supplier"
        }
      ]
    },
    "sk": {
      "presence": "exists",
      "values": [
        {
          "definition": ""SUPPLIER""
        }
      ]
    },
    "supplier": {
      "virtual": true,
      "type": "S",
      "values": [
        {
          "definition": "MID(pk, FIND("#", pk) + 1, LEN(pk))"
        }
      ]
    },
    "data": {
      "presence": "any",
      "type": "S",
      "values": [
        {
          "definition": "country + "#" + region + "#" + city + "#" + address"
        }
      ]
    },
    "country": {
      "virtual": true,
      "type": "S",
      "values": [
        {
          "definition": "LEFT(data, FIND("#", data)-1)"
        }
      ]
    },
    "region": {
      "virtual": true,
      "type": "S",
      "values": [
        {
          "definition": "MID(data, FIND("#", data)+1, FIND("#", data, FIND("#", data)+1)-FIND("#", data)-1)"
        }
      ]
    },
    "city": {
      "virtual": true,
      "type": "S",
      "values": [
        {
          "definition": "MID(data, FIND("#", data, FIND("#", data)+1)+1, FIND("#", data, FIND("#", data, FIND("#", data)+1)+1)-FIND("#", data, FIND("#", data)+1)-1)"
        }
      ]
    },
    "address": {
      "virtual": true,
      "type": "S",
      "values": [
        {
          "definition": "RIGHT(data, LEN(data)-FIND("#", data, FIND("#", data, FIND("#", data)+1)+1))"
        }
      ]
    }
  }
}