Based on the MLA-C01 exam guideReport an error
Simply dropping objects into S3 lets you neither analyze nor train. You have to know "what data is in this bucket, with what schema" before you can query it with Athena and train on it with SageMaker.
The Glue Data Catalog is a Hive Metastore-compatible metadata repository. It stores not the data itself but information about the data — table names, columns, types, S3 locations, partitions.
Glue Data Catalog structure:
Database (logical grouping)
└─ Table (S3 location + schema + partitions)
├─ Columns: customer_id (string), amount (double), ts (timestamp)
├─ Location: s3://ml-datalake/curated/transactions/
├─ SerDe: parquet
└─ Partitions: year=2026/month=06, year=2026/month=05, ...
This catalog is referenced in common by Athena, Redshift Spectrum, EMR, SageMaker, and Glue ETL. Register it once and every analytics/ML tool sees the same schema.
| What it stores | What it does not store |
|---|---|
| Table and column names and types | The actual data rows |
| S3 location (Location) | A copy of the data |
| File format · SerDe | Transformation logic |
| Partition list | Query results |
The Glue Data Catalog is a concept inherited from Apache Hive's Metastore. Hive was a system Facebook built in 2009 to use SQL on top of HDFS, and its core idea was to "separate the data (HDFS files) from the schema (Metastore)." This separation is exactly schema-on-read. Unlike a traditional DB (schema-on-write) that enforces the schema when data is written, a data lake first stores the original and applies the schema when reading. Thanks to this, it can flexibly accept data of various formats and sources.
| Aspect | schema-on-write (traditional DB) | schema-on-read (data lake) |
|---|---|---|
| When the schema is enforced | When data is inserted | When data is read |
| Flexibility | Low (must be defined in advance) | High (accepts the original as is) |
| Quality guarantee | Guaranteed at the entrance | The reading side is responsible |
| Fit for ML | Structured only | Structured, semi-structured, and unstructured |
When S3 holds thousands of files, defining tables one by one is impractical. A Glue Crawler scans S3 (or a JDBC source), automatically infers the schema, and creates tables in the catalog.
How a crawler works:
key=value directories as partitionsimport boto3
glue = boto3.client("glue")
glue.create_crawler(
Name="transactions-crawler",
Role="arn:aws:iam::123456789012:role/GlueCrawlerRole",
DatabaseName="ml_datalake",
Targets={"S3Targets": [{"Path": "s3://ml-datalake/curated/transactions/"}]},
Schedule="cron(0 2 * * ? *)", # every day at 02:00 UTC
)
glue.start_crawler(Name="transactions-crawler")If files with different schemas are mixed in the same folder, a crawler either splits them into several tables or merges them into one. This behavior is controlled by the crawler's "schema change policy" and "grouping behavior" settings. Exam trap: when you rerun a crawler and a new column has been added, it updates the schema by default, but depending on the policy it may ignore a column deletion. Also, using the "crawl new folders only" option so the crawler does not fully rescan the partitions every time reduces cost.
A crawler is not the only way to make new partitions recognized.
| Method | How | When it is advantageous |
|---|---|---|
| Rerun the Glue Crawler | Scan the path and register automatically | When the schema changes too |
MSCK REPAIR TABLE | Athena sweeps the Hive-style paths and registers partitions | When only the partitions have grown |
ALTER TABLE ADD PARTITION | Explicitly add a specific partition | When adding only a few partitions |
| Partition projection | Define the path rule up front and compute without scanning | When partitions are very numerous and regular |
⚠️ Trap: In a scenario like "I added a partition but Athena cannot find it," unconditionally choosing to rerun the crawler may not be the best in terms of cost and time. If only the partitions grew with no schema change,
MSCK REPAIR TABLEor partition projection is lighter.
If the catalog is "what is where," a Glue ETL Job is "how the data is transformed." It runs serverless on top of Apache Spark (or Python Shell, Ray).
The core abstraction is the DynamicFrame. It is similar to a Spark DataFrame, but it is strong at handling semi-structured data whose schema is not uniform (for example, resolving type conflicts with ResolveChoice).
import sys
from awsglue.context import GlueContext
from pyspark.context import SparkContext
glueContext = GlueContext(SparkContext.getOrCreate())
# Read from the catalog
dyf = glueContext.create_dynamic_frame.from_catalog(
database="ml_datalake", table_name="raw_transactions"
)
# Drop missing values + select columns (cleansing)
cleaned = dyf.drop_nulls().select_fields(["customer_id", "amount", "ts"])
# Write to the Curated zone as Parquet (partitioned)
glueContext.write_dynamic_frame.from_options(
frame=cleaned,
connection_type="s3",
connection_options={
"path": "s3://ml-datalake/curated/transactions/",
"partitionKeys": ["year", "month"],
},
format="parquet",
)A Glue Job's billing unit is the DPU (Data Processing Unit) — 4 vCPU + 16GB memory — and it is proportional to run time. It is serverless, so there is no cluster provisioning.
Three execution types of Glue ETL — data size decides the choice.
| Type | Engine | Suitable data | Caution |
|---|---|---|---|
| Spark | Distributed Spark | Large-scale transformations of several GB to TB | Cluster start-up overhead |
| Python Shell | Single Python process | Simple scripts for several MB to several hundred MB | No distributed processing |
| Glue Streaming | Spark Structured Streaming | Kinesis/Kafka micro-batches | Always-on running cost |
Using a Spark Job on small data is slow and expensive because of the cluster start-up overhead. On the exam, for "a small transformation of a few MB," Python Shell is the better fit.
You should know the difference between ETL (Extract-Transform-Load) and ELT (Extract-Load-Transform). Traditional ETL transforms first and then loads into a data warehouse. In a cloud data lake, ELT — load into Raw first, then Transform — is common, because S3 is cheap and compute can be separated. Glue supports both, but in a data lake context the ELT pattern is used often.
When a data scientist wants to cleanse and transform data visually without writing Spark code, use Glue DataBrew.
| Aspect | Glue ETL Job | Glue DataBrew |
|---|---|---|
| Interface | Code (PySpark/Scala) | No-code GUI |
| User | Data engineer | Data analyst/scientist |
| Scale | Large-scale distributed | Small to medium + profiling |
| Strength | Complex custom logic | Fast exploration and cleansing, visualization |
| Reuse unit | Script | Recipe |
| Answer keywords | "large-scale transformation", "custom logic" | "no-code", "non-technical users", "profiling" |
DataBrew's real value is data profiling in ML preprocessing. Before building a model, you can quickly discover facts like "this column has a 40% missing rate" or "this feature has zero correlation with the target" without code. This connects directly to the EDA (Exploratory Data Analysis) covered on Day 3.
S3 Raw zone (JSON/CSV)
│
├─ Glue Crawler ──→ Glue Data Catalog (schema registration)
│ │
│ └──> Shared by Athena / Redshift Spectrum / EMR / SageMaker
│
├─ Glue ETL Job ──→ Cleansing and transformation (DynamicFrame, Spark)
│ or
├─ Glue DataBrew ──→ No-code cleansing and profiling
│
▼
S3 Curated zone (Parquet, partitioned)
│
▼
Athena / Redshift / SageMaker (Day 3, training)
Tool selection summary
| Requirement | Answer |
|---|---|
| Automatically register the schema of thousands of files | Glue Crawler |
| Several engines share the same table definitions | Glue Data Catalog |
| Large-scale distributed transformation, custom logic | Glue ETL Spark Job |
| Simple transformation of a few MB, avoiding overhead | Glue Python Shell Job |
| Visual cleansing and profiling without code | Glue DataBrew |
| Transform a stream in micro-batches | Glue Streaming Job |
Glue is serverless but not free. The charge is the number of DPUs × run time, so a bad configuration quietly becomes expensive.
| What to adjust | If raised | If lowered | Decision criterion |
|---|---|---|---|
| DPU count (workers) | Parallelism up, run time down | Cost down, run time up | Does the data actually parallelize? |
| Job type | Spark is strong at large scale | Python Shell starts faster | Data size (a few MB vs GB and above) |
| Number of input files | Parallel reads possible | Too many files add overhead | Keep any single file from being too large or too small |
| Output partitioning | Later query scan volume down | Too many partitions raise metadata | The consuming side's query patterns |
| Job bookmark | Prevents reprocessing already processed data | If turned off, everything is reprocessed every time | Whether processing is incremental |
| Situation | Cause | Response |
|---|---|---|
| The same folder splits into several tables | Each file has a different schema | Separate the paths or adjust the grouping policy |
| Crawler cost keeps rising | It rescans all partitions every time | Use the "crawl new folders only" option |
| A column was deleted but remains in the catalog | The schema change policy ignores deletions | Set the policy explicitly |
| Athena cannot find a new partition | The partition is not registered in the catalog | MSCK REPAIR TABLE or partition projection |
| A type is inferred differently from what was intended | Limits of the classifier's automatic inference | Specify a custom classifier or edit the table definition |
⚠️ Trap: A crawler is not "run it once and you are done." In a lake where data keeps arriving, you need to judge when to run it periodically on a schedule, or switch to a lighter means when only the partitions are growing.
| Question | Judgment |
|---|---|
| Is the data a few MB or GB and above? | MB means Python Shell, GB and above means Spark |
| Is the schema irregular? | Use DynamicFrame's ResolveChoice |
| What is the output format? | For analytics/training, Parquet + Snappy |
| What do you partition by? | The column the consuming side filters on most often |
| Do you reprocess everything each time? | Incremental processing with job bookmarks |
| Is there someone who can write code? | If not, DataBrew; if so, an ETL Job |
| Is the original preserved? | Never overwrite the Raw zone |
In the next note we query the data prepared this way with Athena and Redshift and look at the basics of EDA (Exploratory Data Analysis).
Click a choice to reveal the answer and explanation.
Question 1
A data engineer wants to automatically register thousands of Parquet files in S3 to Glue Data Catalog without manually defining schemas. What is the most suitable tool?
Question 2
A data analyst wants to profile and clean data by detecting nulls and outliers using a visual interface, without writing code. Which service is most suitable?
Question 3
What is the most accurate description of Glue Data Catalog's core role?
Question 4
For a small dataset (few MB) requiring simple transformation, which Glue Job type avoids Spark cluster startup overhead and costs?
Question 5
JSON data coming to the S3 Raw zone must be made efficient for ML training. What is the recommended output approach in Glue ETL?