Data Type Schema Mapping Rules

The following table lists the data type rules for Avro conversion:

Schema Type Input Payload Type Output Payload Type Explanation
Record Record Record A record in the input payload that is defined as a record in the schema file is also treated as a record in the output payload.
Record Single element array Record A single element array in the input payload is treated as a record in the output payload.
Record Multi element array Empty record If an array contains multiple elements, it’s unclear which element to include in the record. As a result, the record in the output payload will be empty.
Array Record Array A record from the input payload that is defined as an array in the schema file will be included in the output payload and stored as an array.
Array Array Array An array in the input payload defined as an array in schema file is treated as an array in the output payload.

Examples of data type rules for Avro conversion when the schema defines a field as a record.

The examples in this section are based on the following schema:

{
  "type": "record",
  "name": "ContactAndKids",
  "fields": [
	{
    "name": "MyContact",
	  "siebelName": "Contact",
	  "type": {
		"type": "record",
		"name": "Contact",
		"fields": [
            	{
			  "name": "ContactId",
			  "type": "string"
			},
			{
			  "name": "First_Name",
			  "type": "string",
			  "siebelName": "First Name"
			}
            	{
              	"name": "Account",
              	"type": {
			      	"type": "record",
				"name": "Account",
				"fields": [
					{
					  "name": "Name",
					  "type": "string"
					}
					]
			  	}
            	}
	
          	]
	  	}
    }
   ]
}
Input Payload Output Payload Explanation
{
    "Contact": {
        "First Name": "Jack",
        "Last Name": "Doe",
        "ContactId": "1234",
        "Account": [
            {
                "Name": "Test Account1",
                "CSN": "88-36MIAD"
            }
         ]
    }
}
{
    "MyContact": {
        "ContactId": "1234",
        "First_Name": "Jack",
        "Account": {
            "Name": "Test Account1"
        }
    }
}

The example schema defines both Contact and Account as records. However, in the input payload Contact is defined as a record and Account is defined as a single element array. As a result, Account is included as a record in the output payload.

{
    "Contact": {
        "First Name": "Jack",
        "Last Name": "Doe",
        "ContactId": "1234",
        "Account": [
            {
                "Name": "Test Account1",
                "CSN": "88-36MIAD"
            },
            {
                "Name": "Test Account2",
                "CSN": "88-36MIAP"
            }
         ]
    }
}
{
    "MyContact": {
        "ContactId": "1234",
        "First_Name": "Jack",
        "Account": {
            "Name": ""
        }
    }
}

In this sample input payload, Contact is defined as a record and Account is defined as an array with two elements. As a result, Contact is included as a record in the output payload, while Account is not included.

Examples of data type rules for Avro conversion when the schema defines a field as an array.

The examples in this section are based on the following schema:

{
  “type”: “record”,
  “name”: “ContactAndKids”,
  “fields”: [
    {
      “name”: “MyContact”,
      “siebelName”: “Contact”,
      “type”: {
        “type”: “record”,
        “name”: “Contact”,
        “fields”: [
            {
              “name”: “ContactId”,
              “type”: “string”
            },
            {
              “name”: “First_Name”,
              “type”: “string”,
              “siebelName”: “First Name”
            },
            {
              “name”: “Account”,
              “type”: {
                  “type”: “array”,
                    “items”: {
                      “type”: “record”,
                      “name”: “Account”,
                      “fields”: [
                   {
                      “name”: “Name”,
                      “type”: “string”
                    }
                    ]
                    }
              }
            }
    
          ]
      }
    }
   ]
}
Input Payload Output Payload Explanation
{
    “Contact”: {
        “First Name”: “Jack”,
        “Last Name”: “Doe”,
        “ContactId”: “1234”,
        “Account”: {
            “Name”: “Test Account1”,
            “SingleRecordAsJSONObject”: “true”,
            “CSN”: “88-36MIAD”
        }
    }
}
{
    “MyContact”: {
        “ContactId”: “1234”,
        “First_Name”: “Jack”,
        “Account”: [
            {
                “Name”: “Test Account1”
            }
        ]
    }
}

In this input payload, Account is included as a record, even though it is defined as an array in the sample schema. As a result, the output payload contains Account as a single element array.

Therefore, if the schema defines a field as an array, but the input payload includes it as either an array or a record, the output payload will represent the field as an array.