XDM field type constraints
In Experience Data Model (XDM) schemas, a field’s type constrains what kind of data the field can contain. This document provides an overview of each core field type, including the other serialization formats they can be mapped to and how to define your own field types in the API in order to enforce different constraints.
Getting started
Before using this guide, please review the basics of schema composition for an introduction to XDM schemas, classes, and schema field groups.
If you plan on defining your own field types in the API, it is strongly recommended that you start with the Schema Registry developer guide to learn how to create field groups and data types to include your custom fields in. If you are using the Experience Platform UI to create your schemas, see the guide on defining fields in the UI to learn how implement constraints on fields that you define within custom field groups and data types.
Base structure and examples basic-types
XDM is built on top of JSON Schema, and therefore XDM fields inherit a similar syntax when defining their type. Understanding how different field types are represented in JSON Schema can help indicate the base constraints of each type.
The following table outlines how each XDM type is represented in JSON Schema, along with an example value that conforms to the type:
{"type": "string"}
"Platinum"
{"type": "number"}
12925.49
{
"type": "integer",
"maximum": 9007199254740991,
"minimum": -9007199254740991
}
1478108935
{
"type": "integer",
"maximum": 2147483648,
"minimum": -2147483648
}
24906290
{
"type": "integer",
"maximum": 32768,
"minimum": -32768
}
15781
{
"type": "integer",
"maximum": 128,
"minimum": -128
}
90
{
"type": "string",
"format": "date"
}
"2019-05-15"
{
"type": "string",
"format": "date-time"
}
"2019-05-15T20:20:39+00:00"
{"type": "string"}
true
*All date-formatted strings must conform to the ISO 8601 standard (RFC 3339, section 5.6).
Mapping XDM types to other formats
The sections below describe how each XDM type maps to other common serialization formats:
Parquet, Spark SQL, and Java parquet
BYTE_ARRAY
Annotation:
UTF8
StringType
java.lang.String
DOUBLE
LongType
java.lang.Double
INT64
LongType
java.lang.Long
INT32
Annotation:
INT_32
IntegerType
java.lang.Integer
INT32
Annotation:
INT_16
ShortType
java.lang.Short
INT32
Annotation:
INT_8
ByteType
java.lang.Short
INT32
Annotation:
DATE
DateType
java.util.Date
INT64
Annotation:
TIMESTAMP_MILLIS
TimestampType
java.util.Date
BOOLEAN
BooleanType
java.lang.Boolean
MAP
-annotated group(
<key-type>
must be STRING
)MapType
(
keyType
must be StringType
)java.util.Map
Scala, .NET, and CosmosDB scala
String
System.String
String
Double
System.Double
Number
Long
System.Int64
Number
Int
System.Int32
Number
Short
System.Int16
Number
Byte
System.SByte
Number
java.util.Date
System.DateTime
String
java.util.Date
System.DateTime
String
Boolean
System.Boolean
Boolean
Map
object
MongoDB, Aerospike, and Protobuf 2 mongo
string
String
string
double
Double
double
long
Integer
int64
int
Integer
int32
int
Integer
int32
int
Integer
int32
date
Integer
(Unix milliseconds)
int64
(Unix milliseconds)
timestamp
Integer
(Unix milliseconds)
int64
(Unix milliseconds)
bool
Integer
(0/1 binary)
bool
object
map
map<key_type, value_type>
Defining XDM field types in the API define-fields
The Schema Registry API allows you to define custom fields through the use of formats and optional constraints. See the guide on defining custom fields in the Schema Registry API for more information.