Python data engineering interview problem. Difficulty: advanced. Pattern: OOP. About 20 minutes. Part of the Pro drill bank.
A job writes a transaction log that must close even if the body fails. A context manager is the Python way to guarantee setup/teardown.
Implement a context manager that records a scoped transaction log as the tests specify.
Input: run_transaction(['ok', 'ok']) Output: {'status': 'committed', 'ran': 2} This input follows the stated rules and produces this output.
Topics: lakebench, python, OOP.
More Python interview questions · All interview problems · Learn data engineering
Interview-style drill: Write a context manager that records whether a block of operations completed or raised an error.
Implement a context manager that records a scoped transaction log as the tests specify.