Data Store Management · Topic 5 of 7

Glue Data Catalog and Crawlers

Learn how the AWS Glue Data Catalog, crawlers and partition management give Athena, Redshift Spectrum, EMR and Glue jobs one shared schema layer.

  • 5 min
In a nutshell
  • The Glue Data Catalog is a central metadata store and is Hive metastore compatible.
  • Athena, Redshift Spectrum, EMR, Glue and Lake Formation share it.
  • Crawlers infer schema, detect partitions and create tables. They do not move or copy data.

What it is

A data catalog is a central index of what data exists and what it looks like. It records databases, tables, columns, data types, locations and partitions, but it does not store the data itself.

The AWS Glue Data Catalog is the managed catalog for AWS analytics. Athena, Redshift Spectrum, EMR, Glue jobs and Lake Formation all read the same definitions, so you describe a dataset once.

S3 filesraw datascanned byGlue crawlerinfers schemawritesData Catalogtables and partitionsused byAthenaSpectrum, EMR, Glue

How it works

What the catalog holds

The catalog is organized as databases that contain tables. A table has a schema, a location such as an S3 prefix, the data format, the serialization library (SerDe) that reads it and a list of partitions. The catalog is compatible with the Apache Hive metastore, so EMR and other Hive aware tools can use it as their metastore.

Tables can point at S3, JDBC sources, DynamoDB, Kinesis and Kafka. The catalog stores metadata only, so dropping a table does not delete the files in S3 for external tables.

Crawlers

A crawler connects to a data store, samples the data, infers the schema and creates or updates tables in the catalog. Classifiers identify formats such as CSV, JSON, Parquet and Avro, and you can add custom classifiers when the built in ones guess wrong.

Crawler settingPurpose
Data sourceS3 paths, JDBC, DynamoDB and others
ScheduleOn demand, hourly, daily or custom
IAM rolePermission to read the data and write the catalog
Schema change policyUpdate the table definition or only log changes; handle deleted objects
Output database and prefixWhere the tables appear

Crawlers also detect Hive style partitions in S3 paths and add them to the table. A crawler can run on S3 event notifications so it only looks at new data, which is cheaper than scanning a whole prefix every time.

Other ways to build the catalog

Crawlers are not the only way. You can write definitions yourself in DDL (data definition language), through the API, CloudFormation or Glue ETL jobs that update the catalog as they write. In Athena you create a table with CREATE EXTERNAL TABLE.

CREATE EXTERNAL TABLE orders (
  order_id bigint, amount double)
PARTITIONED BY (order_date string)
STORED AS PARQUET
LOCATION 's3://my-bucket/curated/orders/';

MSCK REPAIR TABLE orders;

Keeping partitions current

New partitions in S3 are invisible to queries until the catalog knows about them. You have several choices.

  • Run a crawler on a schedule or on new data.
  • Run MSCK REPAIR TABLE in Athena to discover Hive style partitions.
  • Use ALTER TABLE ADD PARTITION or a Glue API call from your ETL job.
  • Use partition projection in Athena, which calculates partitions from rules in table properties, with no catalog entries to maintain.

Partition projection suits tables with predictable partitions such as dates, and it speeds up planning on tables with many partitions.

Schema evolution and the registry

Source data changes over time. Crawlers can update the table when columns are added, according to the schema change policy. For streaming data, the AWS Glue Schema Registry stores schemas for Avro, JSON Schema and Protocol Buffers and checks that new versions follow a compatibility rule, such as backward or forward compatible, before producers use them.

Connections, security and governance

A Glue connection stores how to reach a data source, such as a JDBC URL, network settings and the secret that holds the credentials. Catalog access is controlled with IAM and with Lake Formation, which can grant permissions down to table, column and row level. The catalog can be shared across accounts with Lake Formation or with AWS Resource Access Manager.

Data lineage and discovery are easier when tables carry descriptions and tags, and Lake Formation tags (LF tags) can then drive permissions.

Catalog statistics

Column statistics stored in the catalog can help engines plan queries. They are optional, and they matter most for large tables with many joins.

What to remember for the exam

  • The Glue Data Catalog is a central metadata store and is Hive metastore compatible.
  • Athena, Redshift Spectrum, EMR, Glue and Lake Formation share it.
  • Crawlers infer schema, detect partitions and create tables. They do not move or copy data.
  • A crawler needs an IAM role that can read the source and write the catalog.
  • New partitions need a crawler run, MSCK REPAIR TABLE, ADD PARTITION or partition projection.
  • Partition projection avoids storing partitions in the catalog.
  • Glue Schema Registry enforces schema compatibility for streaming data.
  • Lake Formation secures the catalog at table, column and row level.
Exam tip

When the question asks for the least effort way to keep a date partitioned Athena table up to date, partition projection is a strong answer.

Common mistakes

Thinking the catalog holds data. It holds metadata. The data stays in S3 or the source store.

Forgetting to refresh partitions. A table with stale partitions returns no rows for new data.

Crawling too often over huge prefixes. Frequent full scans cost money. Use event based crawling or explicit partition calls.

Mixing schemas in one location. A crawler may create odd tables or merge them when files under one prefix differ.

Watch out

A crawler can change a table schema when the source changes, so set the schema change policy deliberately to avoid surprises in downstream queries.

Check yourself

  • What does a Glue crawler do?

    It scans a data store, infers the schema and partitions, and writes table definitions to the Data Catalog.

  • Name one way to make Athena see new partitions without a crawler.

    Run MSCK REPAIR TABLE, add partitions with ALTER TABLE ADD PARTITION, or use partition projection.

  • Which service stores and checks schema versions for streaming data?

    The AWS Glue Schema Registry.

Topic 5 of 7 in Data Store Management

Test yourself on Data Store Management

The full AWS DEA-C01 question bank has 845 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by AWS. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.