0
0
Kafkadevops~5 mins

Avro schema definition in Kafka - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is an Avro schema?
An Avro schema is a JSON-based format that defines the structure of data, including fields and their types, used to serialize and deserialize data in Kafka.
Click to reveal answer
beginner
What are the main components of an Avro schema?
The main components are: <br>1. type: The data type (e.g., record, string, int).<br>2. name: The name of the record.<br>3. fields: A list of fields with their names and types.
Click to reveal answer
beginner
How do you define a record type in Avro schema?
You define a record by specifying "type": "record", giving it a "name", and listing its "fields" with their names and types.
Click to reveal answer
intermediate
What is the purpose of the namespace in an Avro schema?
The namespace groups related schemas together, like a folder name, to avoid name conflicts between schemas with the same record name.
Click to reveal answer
intermediate
How do you specify optional fields in an Avro schema?
You use a union type with "null" and the actual type, for example: ["null", "string"]. This means the field can be a string or null (optional).
Click to reveal answer
Which data type is used to define a complex structure in Avro schema?
Aboolean
Brecord
Cint
Dstring
How do you make a field optional in Avro schema?
ALeave the field out
BSet 'optional': true
CUse 'nullable': true
DUse a union with 'null' and the field type
What is the purpose of the 'namespace' in an Avro schema?
ATo specify the data type
BTo list the fields
CTo group related schemas and avoid name conflicts
DTo define default values
Which format is used to write Avro schemas?
AJSON
BXML
CYAML
DCSV
What does the 'fields' array in an Avro schema contain?
AList of field names and their types
BList of namespaces
CList of default values
DList of schema versions
Explain how to define a simple Avro schema for a user record with name (string) and age (int).
Think about the 'type', 'name', and 'fields' keys.
You got /4 concepts.
    Describe how to make a field optional in an Avro schema and why it is useful.
    Consider how to allow a field to be missing or null.
    You got /3 concepts.