Attribute data types and sample values
Regular attributes and compound attributes have data types defined when created in the CDP on Business Explorer. It is important to write attribute definitions in a way that is compatible with the data type defined in the setup in Business Explorer.
This article will list the data types available in regular and compound attributes, and provide sample values and/or definitions for each data type.
Data types
boolean
true/false values in Segment builder appear as Yes/No. That being said, in attribute calculations, it needs to be of type “text” with values of “1”/”0”, “1” for true and “0” for false.
date
Date value without time component. The date string format needs to be parseable by this library: https://pypi.org/project/ciso8601/
datetime
Datetime value. The date time string format needs to be parseable by this library: https://pypi.org/project/ciso8601/
float
Floating point value.
integer
Integer value.
string
String value. The maximum length of a string value is 256 characters.
Attribute Examples
Data type |
Sample attribute definition (“value” property) |
Sample value |
boolean |
case payload->>’active’ when ‘yes’ then ‘1’ else ‘0’ end |
“1” |
date |
(payload->>’timestamp’)::date |
“2022-03-07” |
datetime |
(payload->>’timestamp’)::timestamp |
“2022-03-07T14:00:00Z” |
float |
payload->>’amount’ |
“5.3” |
integer |
payload->>’count’ |
“2” |
string |
payload->>’value’ |
“sample value” |
Learn More: Resulting values will be converted to strings in regular attributes. To see the resulting queries from attribute definitions, check “out/files/attr_function.sql” in the CPS component in Meiro Integrations after the attribute definitions have been implemented in the database and CPS is running.
Warning: For compound attributes, you have to make sure that all values in the resulting JSON string are all strings. (As stated here : https://docs.meiro.io/link/194#bkmrk-the-value-is%2C-again%2C)