Python data engineering interview problem. Difficulty: intermediate. Pattern: Strings. About 15 minutes. Part of the Pro drill bank.
A log file is too large to load at once. A helper should iterate lines and yield only the ones that look like errors.
Lazily filter a log iterator to error lines.
Input: parse_error_lines(['INFO: ok', 'ERROR: disk', 'ERROR: timeout ']) Output: [{'level': 'ERROR', 'msg': 'disk'}, {'level': 'ERROR', 'msg': 'timeout'}] This input follows the stated rules and produces this output.
Topics: lakebench, python, iterators.
More Python interview questions · All interview problems · Learn data engineering
Interview-style drill: Given an iterator of raw log lines, return a generator that yields only parsed error entries.
Lazily filter a log iterator to error lines.