Skip to the page
Tecyfy

AWS interview question · medium

You have a large CSV file in S3 that needs to be analyzed. Describe two different approaches you could take using AWS services, highlighting the trade-offs of each.

The short answerTwo good approaches are to query the file in place with Amazon Athena, or to process it with Spark on AWS Glue or Amazon EMR.

The full answer

Two good approaches are to query the file in place with Amazon Athena, or to process it with Spark on AWS Glue or Amazon EMR. Athena is quickest to start and cheapest for a few queries; Spark is better for heavy, repeated transformations or machine learning.

Approach 1: query it with Amazon Athena

  1. Define a table over the file's S3 folder in the Glue Data Catalog (with CREATE EXTERNAL TABLE, or a Glue crawler).
  2. Query it with SQL in Athena.
  3. If it will be queried more than a few times, convert it once to Parquet with a CTAS statement:
CREATE TABLE sales_parquet
WITH (format = 'PARQUET', write_compression = 'ZSTD',
      external_location = 's3://my-bucket/curated/sales/')
AS SELECT * FROM sales_csv;

Trade-offs

  • No infrastructure; results in seconds to minutes; pay per terabyte scanned.
  • On raw CSV, every query reads the whole file, so cost and time grow with each query. Converting to Parquet often cuts the data scanned by a large factor, because only the needed columns are read.
  • A single huge gzipped CSV cannot be split, so one worker reads it serially; uncompressed or split files parallelise better.
  • Limited to SQL; complex multi-step logic becomes awkward.

Approach 2: process it with Spark (AWS Glue, EMR Serverless or EMR)

  1. Read the CSV with an explicit schema.
  2. Clean, join and aggregate it.
  3. Write the result as partitioned Parquet or an Iceberg table, registered in the Data Catalog.

Trade-offs

  • Full programming power: Python, complex joins, user-defined logic and machine learning libraries.
  • Scales to very large data across many workers.
  • Glue and EMR Serverless remove cluster management; EMR on EC2 gives the most control and the lowest cost for steady, heavy use.
  • More setup and start-up time, and you pay for workers while the job runs, even if it waits.

How to choose

  • One-off questions or exploration: Athena.
  • A repeatable pipeline, heavy transformation or ML features: Spark, then query the output with Athena.
  • Many teams combine them: Spark (or Athena CTAS) converts the file to Parquet once, and everyone queries the Parquet with Athena.

Last updated 16 October 2026