Skip to content

Athena and AWS Glue

Amazon Athena and AWS Glue are the serverless halves of a data-preparation and query stack: Glue discovers, catalogues and transforms; Athena queries the result in place with SQL. Neither requires a cluster to be provisioned or managed.

Athena is closest to Presto/Trino — it is built on that lineage. In a self-managed stack it displaces Apache Hive as the SQL query engine over a data lake: both expose SQL over files, but Hive requires a Hadoop cluster and Athena does not.

AWS Glue is closest to self-managed Apache Spark for ETL. Glue runs on Spark but removes cluster provisioning and scaling. Its crawler-and-catalogue side plays the role a schema registry or Hive metastore would otherwise play, and its ingestion and routing side overlaps with tools such as Apache NiFi.

The usual shape is: source data lands in S3 or sits in an operational database; a Glue crawler inspects it and writes table definitions into the Glue Data Catalog; jobs and query engines then read those definitions rather than re-inferring schema each time.

S3 feeds an AWS Glue crawler, which populates the Glue Data Catalog. From the catalog, one path goes to Amazon Athena and on to a BI tool; a second path goes to Amazon Redshift Spectrum, which also reads back through Athena.
Two ways to query catalogued data in S3: Athena reads it directly, or Redshift Spectrum reads it from a warehouse. The BI tool shown as QuickSight is now Amazon Quick Suite.

A serverless data integration service: it scales processing and storage automatically, runs jobs on a schedule or in response to events, and applies data quality rules to what it processes.

  • Inspect data across sources and infer schema
  • Collect metadata — location, format, partitions, column types
  • Support S3, Redshift, RDS and databases reachable from EC2
  • Stores table definitions and where the underlying data lives
  • Read by Amazon EMR, Amazon Redshift, Amazon Athena and Glue jobs, so one schema definition serves every engine
  • Removes the need to redefine tables per query tool
  • Transform data according to catalogued schemas
  • Write to Lake Formation, Redshift, S3 or CloudWatch
  • Authored visually, in Python (PySpark) or in Scala
  • Recommends rules from a sample of the data, and ships predefined rule sets
  • Emits quality metrics and raises alerts when a threshold is breached
  • Lets a pipeline fail loudly on bad input rather than propagating it

A serverless interactive query service for data where it already sits.

  • Standard SQL, with results in seconds to minutes depending on how much data the query scans
  • Queries S3 directly, with no loading step
  • Pay per query, priced on the volume of data scanned
  • Petabyte-scale, with Apache Spark available for non-SQL analysis
  • Federated query reaches beyond S3 through more than thirty prebuilt connectors, covering DynamoDB, DocumentDB, Redshift, OpenSearch, Neptune, MySQL, PostgreSQL, SQL Server, Oracle, Snowflake, Google BigQuery, Kafka and others

Because Athena is priced by data scanned, the two changes that matter most for cost and speed are the same two that matter for performance: store data in a columnar format (Parquet or ORC) and partition it on the columns queries filter by.

  1. Glue crawls unstructured or semi-structured data in S3 and writes schemas into the Data Catalog.
  2. Athena reads those schemas and runs SQL against the underlying objects.
  3. Glue ETL jobs reshape the data into curated tables when repeated queries justify the transformation.

Typical division of labour: Athena for ad-hoc querying, log analysis and BI; Glue for preparation, transformation and loading ahead of analytics or model training.

Athena suits irregular, exploratory workloads. Its cost and latency scale with the data each query scans, so a dashboard refreshing every minute over the same large dataset is usually cheaper and faster on a warehouse. Concurrency limits also make it a poor fit for many simultaneous users.