Data Types in Output Mapping
Data types dictate which mutations and rules can be applied in Output Mapping. Ensure you match the correct data type with each operation. This guide outlines some of the different data types and their limitations.
Remember many of the data types can also be empty. For example, a product might not have a brand
or color
attribute. If you want to handle that, you can use the Empty rule.
In general we have tried to account for as many uses of the different data types in the mutations and rules. But if you find a use case that isn't covered, please let us know, by writing to us on [email protected].
Data Types
Number
A numeric value. Can be used for arithmetic calculations and number formatting.
Text
A sequence of characters. Text mutations like replace, append, or prefix are often used on these fields.
List of Text
An array of text items. Supports mutations like sort, filter, and join.
Converting Data Types
Some mutations like Split
and Join
can change the data type of a field:
- Split: Transforms a text field into a 'List of Text'. For example, splitting a comma-separated list of tags into an array.
- Join: Transforms a 'List of Text' into a text field. For instance, joining multiple color values into a single comma-separated string.
- Take: Transforms a 'List of Text' into a text field. For example, taking the first item in a list of tags. But only if you take a single item.
Boolean
A true or false value. Usually used for flagging or filtering products in your feed.
Date
A timestamp or date value. Specialized mutations can be applied for date formatting and calculations.
How Data Types Affect Mutations and Rules
Understanding the data types is crucial as both rules and mutations are sensitive to them. Using the wrong data type can result in unexpected outcomes.
Examples of Valid and Invalid Uses
Number
- Valid: Using
Calculate
to multiply the price by 1.2. - Invalid: Trying to apply
Join
on a number.
Text
- Valid: Using
Replace
to change "http" to "https" in URLs. - Invalid: Trying to use
Greater Than
on a text field.
List of Text
- Valid: Using
Join
to concatenate a list of color attributes into a single comma-separated string. - Invalid: Using
Calculate
on a list of text.
Boolean
- Valid: Using
Equal
to see if the value istrue
orfalse
. - Invalid: Trying to apply
Split
on a boolean field.
Date
- Valid: Using
Before (Datetime)
rule. - Invalid: Using
Calculate
on a date field.
Using the wrong data type can result in no mutation or rule being applied. So if you're not seeing the expected results, check that the data type seems correct.
Special Cases: Returning a List
If a mutation returns a list, the field it maps to will appear multiple times in the feed. This is common for fields like additional_image_link
where you might have multiple URLs.
When working with list-returning mutations, ensure the targeted field in your product feed can handle multiple entries.
Otherwise use a Join
mutation to concatenate the list into a single string.