AWS Glue

Difficulty: Intermediate

Question

What is AWS Glue, what are its main components, and how would you use it in a data pipeline?

Answer

AWS Glue is a serverless data integration service for ETL (extract, transform, load). It has two halves that are often confused: the Glue Data Catalog, a central metadata store of databases and table schemas that Athena, Redshift Spectrum, and EMR all use, and Glue jobs, managed Apache Spark (or Python) jobs that read raw data, transform it, and write it out in an analytics-friendly format. You pay per second for the compute your jobs and crawlers use, with no clusters to manage.

Main components

  • Data Catalog: tables with columns, types, partitions, and S3 locations. It is Hive metastore compatible, so Spark and other engines can use it.
  • Crawlers: scan data in S3, JDBC databases, or DynamoDB, infer schemas, and create or update catalog tables and partitions.
  • ETL jobs: Spark jobs written in PySpark or Scala, Python shell jobs for small tasks, or visual jobs built in Glue Studio.
  • Triggers and workflows: run jobs on a schedule, on demand, or when another job finishes. Many teams orchestrate with Step Functions or Amazon MWAA (Airflow) instead.
  • Data Quality: rules (DQDL) that check completeness, uniqueness, or value ranges as part of a job.
  • Job bookmarks: remember which data was already processed so incremental runs only pick up new files.

A typical pipeline

  1. Apps and services drop raw JSON or CSV into s3://lake/raw/.
  2. A crawler (or a job that writes to the catalog directly) registers the table.
  3. A Glue Spark job cleans it: drops bad rows, casts types, masks PII such as phone numbers, deduplicates.
  4. The job writes partitioned Parquet (for example by dt=2026-10-12) to s3://lake/curated/ and updates the catalog.
  5. Analysts query the curated tables with Athena, or Redshift loads them for dashboards.

How billing and scaling work

Jobs are billed in DPUs (Data Processing Units, 4 vCPU and 16 GB each) per second, with a 1-minute minimum on current Glue versions. You choose a worker type (G.1X, G.2X, and larger) and a number of workers, or enable auto scaling so Glue adds and removes workers during the run. Flex execution runs non-urgent jobs on spare capacity at a lower price.

When to use Glue, and when not to

SituationBetter choice
Batch ETL over S3 data, schema discovery, a shared catalogGlue
Heavy, long-running Spark with custom tuningAmazon EMR (or EMR Serverless)
Simple SQL transformations of data already in S3Athena CTAS or INSERT INTO
Real-time streaming transformsManaged Service for Apache Flink, or Glue streaming jobs
Replicating an operational database into RedshiftZero-ETL integrations

Gotchas

  • Crawlers can create messy schemas (one table per folder) if files in a path have inconsistent formats. Keep one dataset per prefix, or define tables explicitly.
  • Many small files hurt both Glue and Athena performance; coalesce output into reasonably sized files.
  • Forgetting job bookmarks means reprocessing everything on each run, and duplicate rows downstream.
A Glue-based data lake pipeline. Raw files are catalogued, transformed by a Glue job, and queried as clean Parquet.
  1. Raw data in S3: JSON or CSV dumped by apps and services.
  2. Glue crawler: Infers schema and registers tables in the catalog.
  3. Glue Spark job: Cleans, deduplicates, and masks PII.
  4. Curated Parquet in S3: Partitioned by date for cheap scans.
  5. Athena or Redshift: Analysts query using the Data Catalog.

Code examples

Minimal Glue PySpark job: raw JSON to partitioned Parquet

import sys
from awsglue.context import GlueContext
from awsglue.job import Job
from awsglue.utils import getResolvedOptions
from pyspark.context import SparkContext
from pyspark.sql import functions as F

args = getResolvedOptions(sys.argv, ["JOB_NAME"])
glue = GlueContext(SparkContext.getOrCreate())
job = Job(glue)
job.init(args["JOB_NAME"], args)  # enables job bookmarks

# Read the table the crawler registered in the Data Catalog
raw = glue.create_dynamic_frame.from_catalog(
    database="lake", table_name="raw_orders", transformation_ctx="raw"
).toDF()

clean = (raw.dropDuplicates(["order_id"])
            .filter(F.col("amount_paise") > 0)
            .withColumn("dt", F.to_date("created_at")))

clean.write.mode("append").partitionBy("dt").parquet("s3://lake/curated/orders/")
job.commit()  # saves bookmark state so the next run skips processed files

transformation_ctx plus job.init and job.commit let job bookmarks track progress, so each scheduled run only processes new raw files.

Key points

  • Glue = Data Catalog (metadata) + serverless Spark/Python ETL jobs
  • Crawlers infer schemas and partitions; the catalog is shared by Athena, Redshift Spectrum, and EMR
  • Billing in DPUs per second; worker types, auto scaling, and Flex control cost
  • Job bookmarks enable incremental processing
  • Write partitioned, columnar output (Parquet) for cheap downstream queries

Common follow-up questions

  • What is the difference between the Glue Data Catalog and a Glue job?
  • How do job bookmarks work, and when would you reset them?
  • When would you choose EMR over Glue?
  • How would you handle schema changes in incoming data?

Interview tips

  • Separate the catalog from the ETL engine clearly; mixing them up is a common mistake
  • Describe an end-to-end pipeline (raw to curated to query) rather than listing features
  • Mention partitioned Parquet and small-file problems to show hands-on data engineering awareness

Concepts covered

AWS Glue, Glue Data Catalog, Crawlers, Spark ETL Jobs, Job Bookmarks

More AWS & Cloud Fundamentals questions