A Glue job reprocesses every file on every run
You enabled job bookmarks on a Glue ETL job so each run processes only new files, but every run still reads the whole S3 prefix. What are the usual reasons?
Think it through or sketch an answer first, then open the hint or the solution.
Show a hint
Bookmarks need the job to identify its sources and to say when a run finished.
Show the solution
Bookmarks only work when the job calls job.init() at the start and job.commit() at the end, and when each source read has a stable transformation_ctx. Reading with plain Spark (spark.read) instead of a Glue DynamicFrame source bypasses bookmarks. Renaming the transformation context or resetting the bookmark also makes the next run start from scratch.
Example (Python)
job = Job(glueContext)
job.init(args['JOB_NAME'], args)
orders = glueContext.create_dynamic_frame.from_options(
connection_type='s3',
connection_options={'paths': ['s3://lake/raw/orders/']},
format='json',
transformation_ctx='orders_src') # bookmark state is keyed on this
# ... transform and write ...
job.commit()
Common mistakes
- Forgetting job.commit(), so the bookmark never advances.
- Expecting bookmarks to track files that were modified in place: design sources as append-only.
How did you do? Your answer is saved in this browser and comes back for revision later.
Learn more
- Incremental Processing & Job BookmarksAWS Glue
- A Glue ETL Job (PySpark)AWS Glue