XDM field type constraints
In Experience Data Model (XDM) schemas, a field鈥檚 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. Custom fields names are case-insensitive and must have different names at the same level in your schema.
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": "boolean"}
true*All date-formatted strings must conform to the ISO 8601 standard ().
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_ARRAYAnnotation:
UTF8StringTypejava.lang.StringDOUBLELongTypejava.lang.DoubleINT64LongTypejava.lang.LongINT32Annotation:
INT_32IntegerTypejava.lang.IntegerINT32Annotation:
INT_16ShortTypejava.lang.ShortINT32Annotation:
INT_8ByteTypejava.lang.ShortINT32Annotation:
DATEDateTypejava.util.DateINT64Annotation:
TIMESTAMP_MILLISTimestampTypejava.util.DateBOOLEANBooleanTypejava.lang.BooleanMAP-annotated group(
<key-type> must be STRING)MapType(
keyType must be StringType)java.util.MapScala, .NET, and CosmosDB scala
StringSystem.StringStringDoubleSystem.DoubleNumberLongSystem.Int64NumberIntSystem.Int32NumberShortSystem.Int16NumberByteSystem.SByteNumberjava.util.DateSystem.DateTimeStringjava.util.DateSystem.DateTimeStringBooleanSystem.BooleanBooleanMapobjectMongoDB, Aerospike, and Protobuf 2 mongo
stringStringstringdoubleDoubledoublelongIntegerint64intIntegerint32intIntegerint32intIntegerint32dateInteger(Unix milliseconds)
int64(Unix milliseconds)
timestampInteger(Unix milliseconds)
int64(Unix milliseconds)
boolInteger(0/1 binary)
boolobjectmapmap<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.