CCDAK practice question 18 of 25

Which is an optional field in an Avro record?

Full set: 150 questions
Answer options
A: doc Correct answer
B: name
C: namespace
D: fields
Correct Answer:
A. doc
Explanation

According to the official Apache Avro specification, a record schema is a JSON object that must contain a name and a fields attribute. The doc attribute, which is a JSON string for documentation purposes, is explicitly defined as optional. Its presence or absence has no effect on the data serialization or deserialization logic; it serves only as human-readable metadata. While the namespace attribute is also optional, it has a functional impact by defining the fully qualified name of the record, which is crucial for schema evolution and avoiding naming collisions. Therefore, doc is a purely optional, non-functional field.

Why Incorrect

B. name: This is a required JSON string that provides the name of the record. A record schema is invalid without it.
C. namespace: While technically optional, this field is functionally significant as it qualifies the record's name to create a unique full name, which is critical for schema management.
D. fields: This is a required JSON array that lists all the fields within the record. A record definition is incomplete without it.

References

1. Apache Avro™ 1.11.1 Specification, Schemas, Record: The official specification defines the structure of a record. It states: "A record is a JSON object with the following attributes: ... name: a JSON string providing the name of the record (required). ... doc: a JSON string providing documentation to the user of this schema (optional). ... fields: a JSON array, listing fields (required)."

Source: Apache Avro Documentation, https://avro.apache.org/docs/1.11.1/specification/#records

2. Confluent Documentation, Schemas, Subjects, and Topics, Avro Schema: The Confluent documentation reinforces the Avro specification for use within the Confluent Platform. It details the required and optional components of an Avro schema, noting: "A record definition must include its type (“record”) and a name... It can also include a doc attribute to document the record."

Source: Confluent, Inc. Documentation, https://docs.confluent.io/platform/current/schema-registry/fundamentals/serdes-develop/serdes-avro.html#avro-schema (Section: Avro Schema)

Scroll to Top