Skip to main content
Prequel Import anticipates the case where Source Dataset schemas do not perfectly match target Destination schemas without some mapping and transformation. To support bridging between the two, Prequel supports a number of mapping and transformation options.

Who’s responsible for performing the mapping?

Prequel Import provides tooling to support both the Destination owner (you) to perform the mapping, as well as to expose this experience to your users. If you plan to embed this experience for your customers, please see the Customer Experience guide.
Dataset Mapping

Custom queries

At a full table level, custom SQL queries can be used to transform the Source data. This is a good solution for users that are comfortable with SQL, or who need aggregations or logic that spans multiple rows.

Mapping categories

Each Stream mapping has a field_type that determines how the target Destination field is populated. The two categories are summarized below.

Column mapping

A field mapping copies a Source column value directly into a target Destination field.

Column transformation

An expression mapping computes the target value from one or more Source columns using a formula (expression).
See the example below for a Stream that combines column and transformation mapping.
POST /streams
curl -X POST https://api.prequel.co/import/streams \
  -H "X-API-Key: $PREQUEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "stream": {
      "name": "users-stream",
      "dataset_id": "<DATASET_ID>",
      "destination_id": "<DESTINATION_ID>",
      "mappings": [
        {
          "target_field": "id",
          "field_type": "field",
          "column": { "name": "id" }
        },
        {
          "target_field": "email",
          "field_type": "field",
          "column": { "name": "email_address" }
        },
        {
          "target_field": "customer_segment",
          "field_type": "expression",
          "expression": { "expr": "IF(annual_revenue >= 100000, \"enterprise\", IF(annual_revenue >= 10000, \"mid_market\", \"smb\"))" }
        },
        {
          "target_field": "full_name",
          "field_type": "expression",
          "expression": { "expr": "CONCATENATE(first_name, \" \", last_name)" }
        },
        {
          "target_field": "signup_date",
          "field_type": "expression",
          "expression": { "expr": "TIMESTAMPVALUE(created_at)" }
        },
        {
          "target_field": "source_system",
          "field_type": "expression",
          "expression": { "expr": "\"crm\"" }
        }
      ]
    }
  }'

Expression syntax

Expressions use the expr-lang language. Any operator or built-in function from the expr-lang language definition is supported.

Additional supported functions

Prequel Import also provides the following additional helper functions for common transformations:
FunctionSignatureDescription
TIMESTAMPVALUETIMESTAMPVALUE(text)Parses a date or timestamp string.
IFIF(condition, true_val, false_val) -> anyReturns one of two values based on a condition.
TODAYTODAY() -> stringReturns today’s date.
TEXTSPLITTEXTSPLIT(text, delimiter) -> []stringSplits text on a delimiter.
PROPERPROPER(text) -> stringCapitalizes the first letter of each word.
SUBSTITUTESUBSTITUTE(text, old_text, new_text) -> stringReplaces occurrences of old_text with new_text.
LEFTLEFT(text, num_chars) -> stringReturns the leftmost characters of a string.
RIGHTRIGHT(text, num_chars) -> stringReturns the rightmost characters of a string.
MIDMID(text, start_num, num_chars) -> stringReturns a substring starting at a given position.
LENLEN(text) -> intReturns the length of a string.
FINDFIND(find_text, within_text) -> intReturns the position of find_text in within_text. Case-sensitive.
SEARCHSEARCH(find_text, within_text) -> intReturns the position of find_text in within_text. Case-insensitive.
TEXTTEXT(value, format_text) -> stringFormats a value as a string using the given format.
VALUEVALUE(text) -> float64Parses a numeric string into a float.
CONCATCONCAT([str]...) -> stringConcatenates the given strings.
CONCATENATECONCATENATE([str]...) -> stringConcatenates the given strings.
SHA256SHA256(text) -> stringReturns the SHA-256 hash of the input string.
ANDAND([expr]...) -> boolReturns true if all arguments evaluate to true.
OROR([expr]...) -> boolReturns true if any argument evaluates to true.