Avro Schema
The Apache Avro Specification details the structure of an Avro Schema. Both primitive and complex types are supported.
Primitive types
-
null: no value
-
boolean: a binary value
-
int: 32-bit signed integer
-
long: 64-bit signed integer
-
float: single precision (32-bit)
-
double: double precision (64-bit)
-
bytes: sequence of 8-bit unsigned bytes
-
string: unicode character sequence
Avro Schema example
{
"type": "record",
"name": "person",
"fields": [
{
"name": "name",
"type": "string"
},
{
"name": "age",
"type": "int"
},
{
"name": "pets",
"type": {
"type": "array",
"items": {
"type": "record",
"name": "pet",
"fields": [
{
"name": "name",
"type": "string"
},
{
"name": "type",
"type": {
"type": "enum",
"name": "AnimalType",
"symbols": [
"Cat",
"Dog"
]
}
}
]
}
}
}
]
}
The above schema may be used to serialise the below JSON into a binary Avro representation.
{
"name": "John Doe",
"age": 58,
"pets": [
{
"name": "Milo",
"type": "Dog"
},
{
"name": "Nero",
"type": "Cat"
}
]
}
Was this page helpful?