Extract Embedded Schema from Avro File to JSON
Beginner Mode

Start your terminal to use beginner mode.

Scenario

An Avro file contains user records with an embedded schema. You need to extract the schema definition for documentation or validation purposes.

Task

Write a Python script at /home/interview/extract_schema.py that reads /home/interview/data.avro, extracts its embedded schema, and saves it as a formatted JSON file to /home/interview/schema.json.

Note: The avro Python package is already installed.

Example

Expected output format in /home/interview/schema.json:

{
  "type": "record",
  "name": "User",
  "fields": [
    {"name": "id", "type": "int"},
    {"name": "name", "type": "string"},
    ...
  ]
}

Terminal requires a larger screen

Open this page on a desktop or tablet (≥ 768px) to launch the terminal and practice hands-on.

Linux Terminal Environment

Write and execute your solution in the terminal below.

Sign In

Track

Question Difficulty Company Access
Need more practice in this area? Explore more questions →