Data Sources

A data source represents static data that can be used within your transformation. There are no requirements to the format of the data, except it has to be wrapped in a square bracketed JSON array.

To create a new data source, do it under Data Sources navigation section.

JMES function

In order to use data from a data source in your transformation or in a function, use this syntax:

datasource('dataSourceName', 'column', 'lookFor') 

dataSourceName: Name of the data source to use.

column: Name of the column.

lookFor: Exact match on the value in specified column.

returns: An object in a data source based on the arguments.

Example

In this example we refer directly to data source, and define the metadata in the transformation. Normally, you’d likely derive the metadata from the sample data payload.

[{
    "DocSize" : "USLetter",
    "TableWidth" : 13,
    "PrinterTrayOptions" : {
        "Name" : "Black/White 2",
        "DoubleSided" : false
     }
  }, {
    "DocSize" : "A4",
    "TableWidth" : 11.3,
    "PrinterTrayOptions" : {
        "Name" : "Black/White 2",
        "DoubleSided" : true
    }
}]

Data source is wrapped in square brackets.

Each object of the array consists of a few different values that showcases that multiple data formats (integers, strings and bools) are supported.

{
  //metadata
  DocSize: 'USLetter',

  TableWidth: datasource('My_datasource', 'DocSize', $.DocSize).TableWidth,
  PrinterTray: datasource('My_datasource', 'DocSize', $.DocSize).PrinterTrayOptions
}

The metadata (which might have been taken from the payload, but in this case is defined as a string in the transformation), defines the DocSize as USLetter.

The dataSourceName is “My_datasource”, the column we’re matching is “DocSize”, and the lookFor-value is is the “DocSize”-value defined in the metadata. Using affixes and normal JMESPATH syntax, we return TableWidth and PrinterTrayOptions from the data source based on which DocSize is defined.

{
  "DocSize": "USLetter",
  "TableWidth": 13,
  "PrinterTray": {
    "Name": "Black/White 2",
    "DoubleSided": false
  }
}