You're a data engineer at a logistics platform. Every night, an incremental pipeline retrieves new parcel scans from the parcel_scans table and loads them into the data warehouse. The watermark, which records the timestamp of the last successful load, is stored in the etl_state table in the row where source_name = 'parcel_scans'. The table may also contain rows for other sources. Your task is to retrieve the next batch of scans that the pipeline has not yet processed: scans whose timestamps are strictly greater than the watermark. Scans with unknown timestamps (scan_time IS NULL) are not yet ready and must be excluded.
Return these columns:
- scan_id — scan identifier;
- parcel_code — parcel code;
- hub_code — sorting hub code;
- scan_time — scan timestamp (as stored in the table);
- status — parcel status (may be NULL; return it unchanged).
Sort the result by scan_time in ascending order, breaking ties by scan_id in ascending order. Exclude any scan whose timestamp is exactly equal to the watermark.
scan_idparcel_codehub_codescan_timestatusShowing the first 3 rows of the sample — the full sample comes with Premium
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign in