• v7.0.8
    • v7.11.0 (latest)
    • v7.10.0
    • v7.9.0
    • v7.8.0
    • v7.7.0
    • v7.6.0
    • v7.5.0
    • v7.3.0
    • v7.2.0
    • v7.1.1
    • v7.1.0
    • v7.0.8
  • Services & Support
  • Devo.com
  • Contact
    • Contact Us
    • Request a Demo
    • Partner Inquiry
  • Log In
    • USA Devo
    • EU Devo
PREVIOUS
Join
NEXT
Reducer

Flow / Unit types / Core / Map

Download as PDF

Map

Description

The Map unit is a Processor unit type.

This unit transforms input events by adding/overwriting/removing fields. New/overwritten fields are defined through expressions over existing fields. Expressions can refer to input event fields, as well as to previous expression results. In addition, existing fields can be removed.

An event enters through the in port. The expressions are evaluated and the input is modified to account for new/overwritten/removed fields. Then, the event is output through the out port. 

If there are errors produced during the evaluation, these events are enriched with two additional fields, error and exception, and the event is output through the error port.

Configuration

After dragging this unit into the Flow canvas, double-click it to access its configuration options. The following table describes the configuration options of this unit:

TabFieldDescription
GeneralNameEnter a name for the unit. It must start with a letter, and cannot contain spaces. Only letters, numbers, and underscores are allowed.
LanguageSpecify the language you will use to write the expression, e.g. Javascript, Groovy, etc.
Fields to addEvent fieldThe name of an event field with the data you wish to convert to new columns, written in the correct format (expression, type, name, overwrite combination).

Alternatively, the name of an input event field containing such a list can be entered below using the plus icon.

Fields

Click the plus icon to open the list (expression, type, name, overwrite combination).

Field name

The name of an output event field where the expression result will be inserted.

Type

The expected type for the expression result.

Expression

An expression written in the specified language.

Overwrite

Whether to overwrite an existing input event field if one with the same name already exists.

Fields to removeFieldsA list of field names to remove.

Input ports

PortDescription

in

All events enter through this port. You can refer to event fields using expressions.

Output ports

PortDescription

out

Outputs input events modified with new/overwritten/removed fields. New/Overwritten fields are those defined by expressions in the 'Fields to add' tab.  Removed fields are those defined in the 'Fields to remove' tab.

error

Outputs all events that produced an error during evaluation. These events have two additional fields, error, and exception, that describe the error.

Example

In this example, we will transform data generated by an external web service (RandomUser.me) and add the required fields to get the required information. Then, the data will be sent to a Devo table. 

First, we add a Tick unit to fire events when we require and connect it to an HTTP call unit, configured with the information required to request information to the randomuser API. Then, we will transform the API responses to a JSON object using the JSON Parser unit.

Now, we need to extract the required information from the JSON objects. We will use a Map unit and add the following columns in its properties:

  • Column 1
  • Column 2
  • Column 3
  • Column 4
  • Column 5
  • Column 6
  • Column 7
  • Column 8

This column extracts all the info from the JSON object. From there, we will start extracting the required parts.

  • Field name - all
  • Type - Map
  • Expression - This is the expression that defines the new column:
data.get("results").get(0)

This column extracts the name from the JSON object.

  • Field name - name
  • Type - String
  • Expression - This is the expression that defines the new column:
all.get("name").get("first")

This column extracts the surname from the JSON object.

  • Field name - surname
  • Type - String
  • Expression - This is the expression that defines the new column:
all.get("name").get("last")

This column extracts the gender from the JSON object.

  • Field name - gender
  • Type - String
  • Expression - This is the expression that defines the new column:
all.get("gender")

This column extracts the email from the JSON object.

  • Field name - email
  • Type - String
  • Expression - This is the expression that defines the new column:
all.get("email")

This column extracts the location from the JSON object.

  • Field name - location
  • Type - java.lang.Object
  • Expression - This is the expression that defines the new column:
all.get("location")

This column extracts the city from the JSON object.

  • Field name - city
  • Type - String
  • Expression - This is the expression that defines the new column:
location.get("city")

This column extracts the country from the JSON object.

  • Field name - country
  • Type - String
  • Expression - This is the expression that defines the new column:
location.get("country")

Finally, we will add a Devo Sink unit and set the required Devo table where we want to send our data. This will be the final result:

You can try this flow by downloading this JSON file and uploading it to your domain using the Import option.

Download as PDF

PREVIOUS
Join
NEXT
Reducer

Export

See what Devo can do for you. Request a demo!
Discover what's new (Release notes)
  • v7.0.8
    • v7.11.0 (latest)
    • v7.10.0
    • v7.9.0
    • v7.8.0
    • v7.7.0
    • v7.6.0
    • v7.5.0
    • v7.3.0
    • v7.2.0
    • v7.1.1
    • v7.1.0
    • v7.0.8
  • Services & Support
  • Devo.com
  • Contact
    • Contact Us
    • Request a Demo
    • Partner Inquiry
  • Log In
    • USA Devo
    • EU Devo
  • +1 888 6830910 (USA)
  • +34 900 838 880 (Spain)
Copyright © 2019 Legal Terms Privacy Policy Cookies Policy

Powered by Confluence and Scroll Viewport