Experienced

Data Engineer | 135 questions | 2026

Data Engineer interview questions for experienced

Questions for candidates with 2 to 5 years of experience, by topic. Tap a question to see the model answer.

Advanced SQL

ExperiencedMost askedScenario
Answer

A query that ran in 2 seconds last month now takes 2 minutes. How do you investigate?

Work from evidence, not guesses.

  1. Capture the exact query and its parameters. Run EXPLAIN (ANALYZE, BUFFERS). Compare it with an old plan if you saved one.
  2. Compare estimates with actual numbers. If they are far apart, run ANALYZE on the tables. Data growth or a bulk load may have made the statistics old.
  3. Look for a changed plan. A seq scan may have replaced an index scan. A bad join order may have replaced a good one.
  4. Check table and index bloat (wasted dead space). Check that autovacuum keeps up.
  5. Check for locks and contention in pg_stat_activity. Look for other heavy jobs running at the same time.
  6. Check data growth. The table may have grown to a size where the plan changes. A new uneven value may have appeared.
  7. Check recent changes: a dropped index, a schema migration, a new parameter value, or a version upgrade.

Fix the root cause. It may be statistics, an index, a query rewrite, or partitioning. Then add monitoring with pg_stat_statements so you see the problem early next time.

What they are checking: Do you have a clear, step by step way to debug slow queries?

ExperiencedMost askedFree with sign-in
Answer

What is a recursive CTE? Give an example that walks an employee-manager hierarchy.

A recursive CTE has two parts joined by UNION ALL. The anchor query gives the starting rows. The recursive part refers to the CTE itself. It repeats until the recursive part returns no new rows.

ExperiencedMost askedScenarioFree with sign-in
Answer

What is the gaps and islands problem? How would you find consecutive login days for each user?

Islands are runs of consecutive values. Gaps are the breaks between them. The standard trick is to subtract a ROW_NUMBER from the value. Inside one island, the difference stays the same.

ExperiencedMost askedFree with sign-in
Answer

How would you write a query that returns the value of a Type 2 slowly changing dimension as of a given date?

A Type 2 dimension stores one row per version, with a validity range. Filter on the range with a half-open interval so exactly one row matches.

ExperiencedMost askedScenarioFree with sign-in
Answer

How would you implement an SCD Type 2 load in SQL when new data arrives in a staging table?

Do two steps in one transaction. First close the changed current rows. Then insert the new versions.

ExperiencedMost askedFree with sign-in
Answer

How do you read an EXPLAIN ANALYZE output? What do you look for first?

EXPLAIN shows the planned tree. EXPLAIN (ANALYZE, BUFFERS) runs the query and adds real timings, row counts and block reads. Read from the innermost, most indented node outward.

ExperiencedMost askedFree with sign-in
Answer

Why might the database ignore an index you created?

Common reasons:

ExperiencedMost askedScenarioFree with sign-in
Answer

How would you sessionize clickstream events, grouping events into sessions after 30 minutes of inactivity?

Mark the start of a new session when the gap from the previous event is more than 30 minutes. Then take a running sum of the marks. That sum is the session id.

ExperiencedMost askedFree with sign-in
Answer

How do you perform an upsert in PostgreSQL?

Use INSERT ... ON CONFLICT. It is atomic (all or nothing) and safe when many writers run at once. It needs a unique index or constraint on the conflict column.

ExperiencedMost askedScenarioFree with sign-in
Answer

How do you select the latest record per key, such as the most recent status for each order?

PostgreSQL has a short option called DISTINCT ON. It keeps the first row of each group, based on the ORDER BY.

ExperiencedMost askedScenarioFree with sign-in
Answer

You must delete or update 200 million rows in a production table without locking everyone out. How do you do it?

Avoid one giant transaction. It holds locks, makes the WAL (write-ahead log) very large, and can run for hours.

Options:

  • Do the work in batches of 10,000 to 100,000 rows. Commit after each batch and sleep briefly between batches:
ExperiencedMost askedFree with sign-in
Answer

How do you pivot rows into columns in PostgreSQL?

Use conditional aggregation. It is portable and fast. PostgreSQL has no PIVOT keyword.

ExperiencedMost askedFree with sign-in
Answer

How does column order matter in a composite index?

A B-tree composite index is sorted by the first column. Inside that, it is sorted by the second column, and so on. The index helps only when the query uses a leftmost prefix (the first columns of the index).

ExperiencedMost askedFree with sign-in
Answer

What is table partitioning in PostgreSQL and when would you use it?

Partitioning splits one logical table into physical child tables by a key. Queries and maintenance then touch only the pieces they need.

ExperiencedMost askedFree with sign-in
Answer

What is the difference between ROWS and RANGE in a window frame?

Both define which rows around the current row go into the window function.

ExperiencedMost askedFree with sign-in
Answer

How do you compute a 7-day moving average?

If there is exactly one row per day, use a ROWS frame:

ExperiencedMost askedFree with sign-in
Answer

How do you find the median or a percentile in PostgreSQL?

Use the ordered-set aggregates percentile_cont and percentile_disc. The first interpolates, so it can give a value between two rows. The second returns a real value from the data.

ExperiencedMost askedScenarioFree with sign-in
Answer

How would you calculate user retention by signup cohort in SQL?

Give each user a cohort (their signup month). Work out the months since signup for each activity. Then count distinct active users for each cohort and month offset.

ExperiencedMost askedFree with sign-in
Answer

What is the difference between EXISTS and IN? Which should you use?

Both test whether a value is in a subquery result.

  • IN compares a value to the list of values from the subquery.
  • EXISTS returns true as soon as the correlated subquery finds one row. It does not care about the values.
ExperiencedMost askedFree with sign-in
Answer

What index types does PostgreSQL offer and when do you use each?

  • B-tree (default): equality, ranges and sorting. It is right for most columns.
  • Hash: equality only. It is rarely better than B-tree.
  • GIN: many values per row, such as jsonb, arrays and full-text search.
  • GiST: geometric data, ranges, nearest-neighbour search and full-text search.
  • BRIN: a tiny index for huge...
ExperiencedMost askedFree with sign-in
Answer

Explain nested loop, hash join and merge join. When does the planner pick each?

  • Nested loop: for each outer row, look up the matching inner rows. It is best when the outer side is small and the inner side has an index. The cost grows with the outer rows times the lookups.
  • Hash join: build a hash table on the smaller input, then probe it with the other input. It is good for large unsorted...
ExperiencedMost askedScenarioFree with sign-in
Answer

How do you generate a complete date series and fill in missing days with zero?

Generate the calendar with generate_series. Then LEFT JOIN the data to it.

ExperiencedMost askedFree with sign-in
Answer

What is the difference between a view and a materialized view?

A view stores only a query. Each read runs the query again on current data. A materialized view stores the result on disk. You refresh it when you ask.

ExperiencedMost askedFree with sign-in
Answer

What is a correlated subquery and why can it be slow? How do you rewrite it?

A correlated subquery refers to the outer query. So it logically runs once for each outer row.

ExperiencedMost askedScenarioFree with sign-in
Answer

How can you speed up a slow GROUP BY aggregation on a very large table?

Start with EXPLAIN ANALYZE. Then reduce the work.

ExperiencedFree with sign-in
Answer

What are table statistics, VACUUM and bloat, and why do they matter for query performance?

PostgreSQL uses MVCC (it keeps old row versions). After an UPDATE or DELETE, the old versions stay behind. These dead tuples take space until VACUUM frees it.

ETL and Pipelines

ExperiencedMost asked
Answer

What does it mean for a pipeline to be idempotent, and how do you make one?

An idempotent pipeline gives the same result however many times you run it for the same input. This makes retries and backfills safe.

Techniques:

  • Overwrite by partition: delete and reload one date partition (or use INSERT OVERWRITE) instead of appending.
  • Use upsert or MERGE on a business key, not a plain INSERT.
  • Make outputs predictable: build file names and ids from the input (a hash or batch date), not from now() or random UUIDs.
  • Write to a temp location and swap it in at once on success.
  • Keep a run log keyed by batch id, so a finished batch is skipped.
  • Avoid side effects that cannot be repeated, such as sending emails. Or guard them.
BEGIN;
DELETE FROM fact_sales WHERE sale_date = :run_date;
INSERT INTO fact_sales SELECT * FROM stg_sales WHERE sale_date = :run_date;
COMMIT;

What they are checking: Whether you design for safe reruns, the core DE skill

ExperiencedMost asked
Answer

What is Change Data Capture (CDC) and what are its approaches?

CDC (Change Data Capture) finds inserts, updates and deletes in a source database. It sends them to other systems as they happen.

Approaches:

  • Log-based: read the database transaction log (PostgreSQL WAL, MySQL binlog). It puts little load on the source, captures deletes, and keeps order. Tools: Debezium, AWS DMS.
  • Trigger-based: triggers write changes to an audit table. This adds load to the source.
  • Timestamp or version column: query updated_at > last_run. It is simple, but it misses hard deletes. It can also miss rows if the timestamps are not reliable.
  • Snapshot diff: compare full snapshots. This is heavy.

Log-based CDC is the usual answer for production. Plan for an initial snapshot plus an ongoing stream. Think about order and schema changes. Also decide how deletes appear (a tombstone or an op field). The target applies changes with MERGE on the primary key.

What they are checking: Whether you know log-based CDC and its trade-offs

ExperiencedMost askedScenario
Answer

A nightly pipeline failed halfway through. Some tables loaded and others did not. What do you do?

First make things stable, then fix the cause, then prevent it from happening again.

  1. Assess: read the logs. Find the failed task, the error, and what was already written. Check that the target is in a consistent state for users.
  2. Communicate: tell downstream owners that the data is partial, and until when.
  3. Fix the cause: bad data, schema change, timeout, credentials, or capacity.
  4. Rerun safely: loads should be idempotent, so rerun the failed task and its downstream tasks for the same logical date. Do not rerun the finished ones. In Airflow, clear the failed task instance.
  5. Reconcile: compare row counts and key totals between source and target.
  6. Prevent: write to staging and swap or commit at once. Add retries with backoff, data quality gates, and alerts on failure and freshness.

If the pipeline is not idempotent, fix that first. Make the affected loads partition-overwrite or MERGE, so a rerun cannot create duplicates.

What they are checking: Whether you can recover calmly using idempotency and reconciliation

ExperiencedMost askedScenario
Answer

You discover duplicate records in a target table. How do you find the cause and fix it?

Measure the problem, find the source, fix it, then prevent it.

Find the duplicates:

SELECT order_id, COUNT(*) FROM fact_orders GROUP BY order_id HAVING COUNT(*) > 1;

Check the load timestamps or batch ids on the duplicate rows. If the copies came from different batches, a rerun appended instead of overwriting. If they came from the same batch, the source or a join made them. A one-to-many join can multiply rows. The source may also have sent the record twice.

Fix: keep one row per key with ROW_NUMBER on a rule such as the latest loaded_at. Then rewrite the table or partition.

Prevent:

  • Make loads idempotent (MERGE on the business key or partition overwrite).
  • Add a unique constraint or a dbt unique test on the key.
  • Remove duplicates in staging.
  • Reconcile counts with the source after each load.

Do not just delete rows without knowing the cause. The duplicates will come back.

What they are checking: Whether you look for the root cause, not only a cleanup query

ExperiencedMost askedFree with sign-in
Answer

How do you handle late-arriving data?

First separate event time (when it happened) from processing time (when you received it). Then decide how long you will wait.

ExperiencedMost askedScenarioFree with sign-in
Answer

How do you run a backfill for six months of historical data without disrupting production?

Treat it as a controlled reprocessing job.

ExperiencedMost askedFree with sign-in
Answer

Compare Avro, Parquet and ORC. When do you choose each?

  • Avro: a binary format that stores data row by row, with the schema inside. It handles schema changes well and is compact for writes. Best for streaming (Kafka with a schema registry) and for ingesting one record at a time.
  • Parquet: a column-based format with wide support in Spark, Presto/Trino, BigQuery, Snowflake and Athena. Best for analytics on a data lake.
  • ORC: a column-based format that began in Hive. It has built-in indexes and ACID support in Hive. Strong in Hive and Hadoop setups.
ExperiencedMost askedFree with sign-in
Answer

What is the difference between at-most-once, at-least-once and exactly-once delivery?

  • At-most-once: a message arrives zero or one times. There are no duplicates, but data can be lost.
  • At-least-once: a message arrives one or more times. Nothing is lost, but duplicates are possible after retries.
  • Exactly-once: each message changes the result only once.
ExperiencedMost askedFree with sign-in
Answer

How do you choose a partitioning strategy for data in a lake or warehouse?

Partition by the column that queries filter on most, if it has a moderate number of distinct values. Date is the usual choice for event data.

ExperiencedMost askedScenarioFree with sign-in
Answer

How do you monitor data pipelines and what do you alert on?

Monitor both the jobs and the data.

Job health: failures, retries, run time compared with normal, queue time, resource use, missed schedules.

Data health: freshness (the latest timestamp is recent), volume (row count in an expected range), schema changes, null rate, duplicates, and reconciliation with the source.

ExperiencedMost askedFree with sign-in
Answer

How do you implement an incremental load with a watermark in SQL?

Keep a control table with the last successful high-water mark. Extract rows after it, upsert them, and move the mark forward only on success.

ExperiencedMost askedScenarioFree with sign-in
Answer

Design a pipeline that ingests data from an operational database and delivers dashboards in a warehouse. Walk through your choices.

Start from the needs: freshness, volume, history, and users.

ExperiencedMost askedFree with sign-in
Answer

Explain dbt materializations and how an incremental model works.

Materializations control how a model is stored:

  • view: a saved query, always fresh, no storage.
  • table: rebuilt fully on each run.
  • incremental: after the first run, only new or changed rows are processed.
  • ephemeral: inlined as a CTE, not created in the database.
ExperiencedMost askedFree with sign-in
Answer

What are Delta Lake, Apache Iceberg and Apache Hudi, and why do they exist?

They are open table formats. They add warehouse-like features on top of Parquet files in object storage.

ExperiencedMost askedScenarioFree with sign-in
Answer

You must ingest data from a third-party REST API that has rate limits and occasionally fails. How do you design it?

Design for limits, retries and restarts.

ExperiencedMost askedFree with sign-in
Answer

How do you handle retries, failures and bad records in a pipeline?

Separate temporary failures from bad data.

ExperiencedMost askedFree with sign-in
Answer

How do you protect sensitive data (PII) in a data pipeline?

Protect the data at every stage.

ExperiencedMost askedScenarioFree with sign-in
Answer

A vendor sends CSV files daily, and the columns sometimes change order or a new column appears. How do you make the load robust?

Do not depend on column position.

ExperiencedMost askedFree with sign-in
Answer

How do you test a data pipeline?

Test at several levels.

ExperiencedMost askedScenarioFree with sign-in
Answer

Your cloud data pipeline costs have doubled this quarter. How do you reduce them?

Measure first, then cut the biggest items.

ExperiencedMost askedScenarioFree with sign-in
Answer

How do you handle records deleted in the source system?

Incremental loads based on updated_at never see a hard delete. So you need an explicit approach.

ExperiencedMost askedScenarioFree with sign-in
Answer

What do you do when a daily pipeline starts missing its SLA because it now runs for 6 hours instead of 2?

Treat it as a performance regression and find where the time went.

ExperiencedMost askedScenarioFree with sign-in
Answer

How do you choose between a managed ETL service and serverless functions for data processing jobs, especially for long-running work?

I compare run-time limits, data volume, cost model and effort to operate.

ExperiencedFree with sign-in
Answer

What are Lambda and Kappa architectures?

Both combine historical and real-time processing.

ExperiencedFree with sign-in
Answer

What is a data contract and why are they used?

A data contract is an agreement between a data producer and its consumers. It defines the schema, meaning, quality needs, freshness, ownership, and how changes are shared.

Data Warehousing

ExperiencedMost askedScenario
Answer

Design a star schema for an e-commerce business. What are your fact and dimension tables?

Start with the business process (placing an order). Then declare the grain: one row per order line item.

Fact: fact_order_line

  • Keys: date_key, customer_key, product_key, store_or_channel_key, promotion_key, payment_key.
  • Degenerate dimension: order_number.
  • Measures: quantity, unit_price, discount_amount, tax_amount, net_amount (all additive).

Dimensions:

  • dim_date (day, week, month, quarter, holiday flag).
  • dim_customer (SCD Type 2 for segment and city; keep the natural key).
  • dim_product (name, brand, category, hierarchy).
  • dim_channel, dim_promotion, and a junk dimension for flags like is_gift.

Extras: a separate fact_returns that shares the conformed dimensions. A periodic snapshot for inventory. An accumulating snapshot for order fulfilment (order, ship and delivery dates).

Use surrogate keys. Use an Unknown member (-1) for missing references. Add tests for uniqueness at the grain and for foreign key integrity.

What they are checking: Can you model from start to finish using the Kimball steps?

ExperiencedMost asked
Answer

What types of fact tables are there?

Kimball describes three main types, plus factless tables.

  • Transaction fact: one row per event at the lowest grain (each order line, each click). This is the most common and most flexible.
  • Periodic snapshot: one row per item per period (account balance at month end, daily inventory). It suits status measures that are not events.
  • Accumulating snapshot: one row per process instance. It is updated as the item moves through stages (order placed, shipped, delivered), with several date columns. It is used to study pipelines and lead times.
  • Factless fact: records that an event happened or a link exists, with no number to measure (student attended class, product on promotion).

Pick the type from the business process. Events lead to transaction facts. Regular status checks lead to snapshots. A workflow with milestones leads to accumulating snapshots.

What they are checking: Can you choose the right fact table type?

ExperiencedMost askedFree with sign-in
Answer

How does BigQuery work and how is it priced?

BigQuery is a serverless, columnar data warehouse. Storage (Capacitor format) and compute (Dremel engine) are separate. Google manages the resources.

ExperiencedMost askedFree with sign-in
Answer

What are distribution keys and sort keys in Amazon Redshift?

Redshift is an MPP (massively parallel) columnar warehouse. Data is spread across the slices of the compute nodes. Two table settings change performance.

ExperiencedMost askedFree with sign-in
Answer

What is the difference between partitioning and clustering in a cloud warehouse such as BigQuery or Snowflake?

Both reduce the data scanned, but in different ways.

ExperiencedMost askedScenarioFree with sign-in
Answer

A dashboard query on your warehouse became very slow. How do you troubleshoot it?

First check what the query does and how much data it touches.

ExperiencedMost askedFree with sign-in
Answer

What are conformed dimensions?

Conformed dimensions are dimensions shared by many fact tables or data marts. They have the same keys, attribute names and meanings. Date, customer and product are typical.

ExperiencedMost askedFree with sign-in
Answer

What are Snowflake Time Travel and zero-copy cloning?

Time Travel lets you query, clone or restore data as it was at an earlier time. It works inside a retention window (1 day by default, up to 90 days on higher editions).

ExperiencedMost askedScenarioFree with sign-in
Answer

A customer's attribute is corrected retroactively, for example their region was wrong for the last two years. How do you handle it in your SCD Type 2 dimension?

First decide if it is a correction or a real change.

ExperiencedMost askedFree with sign-in
Answer

How do you model a many-to-many relationship in a dimensional model, such as a patient with multiple diagnoses?

Use a bridge table between the fact (or dimension) and the dimension that has many values.

Structure:

  • fact_visit has a diagnosis_group_key.
  • bridge_diagnosis_group(diagnosis_group_key, diagnosis_key, weighting_factor).
  • dim_diagnosis holds the diagnoses.
ExperiencedMost askedScenarioFree with sign-in
Answer

How do you handle late-arriving facts and late-arriving dimensions in a warehouse load?

Late-arriving fact: the fact shows up after its date. Load it normally. But look up the dimension version that was valid on the event date, not the current one. Then reprocess the aggregates and snapshot tables for that date.

ExperiencedMost askedFree with sign-in
Answer

How do you load a fact table and populate its surrogate keys?

Load dimensions first, then facts, because facts need dimension keys.

ExperiencedMost askedScenarioFree with sign-in
Answer

Model a ride-hailing business in a warehouse. What are the facts and dimensions?

Business process: completed trips. Grain: one row per trip.

ExperiencedMost askedScenarioFree with sign-in
Answer

How would you control and reduce warehouse costs in Snowflake or BigQuery?

Find the cost drivers first: query history, warehouse usage and storage.

ExperiencedMost askedFree with sign-in
Answer

What security and governance features should a data warehouse have?

Key controls:

  • Login and role-based access control with least privilege. Use roles and groups, not grants to single users.
  • Column-level security and masking policies for PII (most users see a masked email).
  • Row-level security, so users see only their own region or tenant.
  • Encryption at rest and in transit, with...
ExperiencedMost askedScenarioFree with sign-in
Answer

You are asked to migrate an on-premises data warehouse to the cloud. How do you plan it?

Plan in phases and keep the risk low.

ExperiencedMost askedScenarioFree with sign-in
Answer

A fact row arrives with a product id that does not exist in the product dimension. What do you do?

Never drop the fact silently, because the totals would be wrong. Choose a documented strategy:

ExperiencedMost askedFree with sign-in
Answer

What are aggregate tables and materialized views in a warehouse, and when do you use them?

Both store results that are calculated in advance. So frequent queries do not need to scan the detailed facts again.

ExperiencedFree with sign-in
Answer

What is Data Vault modeling and how is it different from dimensional modeling?

Data Vault is a modeling method for the integration layer of an enterprise warehouse. It is built for auditing, growth and easy change.

Core parts:

  • Hubs: unique business keys.
  • Links: relationships between hubs.
  • Satellites: descriptive attributes with history. They are loaded with timestamps and the record source.
ExperiencedFree with sign-in
Answer

What is a factless fact table? Give an example.

A factless fact table has foreign keys to dimensions but no numbers to measure. It records that an event happened, or that a relationship exists.

ExperiencedFree with sign-in
Answer

What is a semantic layer or metrics layer, and why use one?

A semantic layer defines business metrics and dimensions once, in a central place (revenue, active customer, churn rate). Every BI tool or notebook then uses those definitions.

ExperiencedFree with sign-in
Answer

What is the difference between a centralised data warehouse and a data mesh?

A centralised warehouse has one central team. The team loads, models and serves data for the whole company. A data mesh spreads ownership. Each business domain owns its data and publishes it as a product.

Spark and PySpark

ExperiencedMost askedFree with sign-in
Answer

What is Adaptive Query Execution (AQE) in Spark 3?

AQE changes the plan while the job runs, using real statistics collected after each shuffle stage. It is on by default since Spark 3.2 (spark.sql.adaptive.enabled).

ExperiencedMost askedFree with sign-in
Answer

What is data skew and how do you handle it in Spark?

Skew means some keys have far more rows than others. A few tasks then run much longer and may run out of memory, while the rest sit idle.

How to spot it: on the stage page in the Spark UI, the max task time and shuffle read are far above the median.

ExperiencedMost askedScenarioFree with sign-in
Answer

What are the common causes of out-of-memory errors in Spark and how do you fix them?

Treat driver out-of-memory (OOM) and executor OOM as two separate problems.

Driver: collect() or toPandas() on a large result, a huge broadcast, or metadata for too many partitions. Fix: write to storage, or use take or limit. Raise spark.driver.memory only as a last step.

ExperiencedMost askedScenarioFree with sign-in
Answer

Your Spark job is slow. How do you investigate and speed it up?

Use the Spark UI before you change anything.

ExperiencedMost askedScenarioFree with sign-in
Answer

How do you remove duplicates in a Spark DataFrame, keeping the latest record per key?

dropDuplicates removes exact or key-based duplicates. It does not let you choose which row stays. For 'latest per key', use a window function.

ExperiencedMost askedFree with sign-in
Answer

Write PySpark code to compute the top 3 products by revenue in each category.

First add up the revenue. Then rank the products inside each category with a window.

ExperiencedMost askedFree with sign-in
Answer

What are the join strategies in Spark SQL?

Spark picks one of these physical strategies:

ExperiencedMost askedFree with sign-in
Answer

When should you cache a DataFrame and when should you not?

Cache a DataFrame when it is expensive to compute and used by several actions or loops. Examples are ML loops, or a table reused by several later branches.

ExperiencedMost askedFree with sign-in
Answer

What is Catalyst optimizer?

Catalyst is the query optimizer of Spark SQL. It uses rules and also cost estimates. It turns a query into an efficient physical plan in four phases:

ExperiencedMost askedFree with sign-in
Answer

How does key salting work? Show an example.

Salting spreads one hot key over several partitions. Add a random number to the key on the big side. Then copy the small side once for every salt value.

ExperiencedMost askedFree with sign-in
Answer

What does partitionBy do when writing data, and what are the pitfalls?

partitionBy("col") writes data into one directory for each column value, such as year=2025/month=10/. Queries that filter on that column skip whole directories (partition pruning).

ExperiencedMost askedFree with sign-in
Answer

How do you decide the number of partitions in Spark?

Aim for partitions of about 100 to 200 MB each. Also aim for at least 2 to 4 tasks per available core. This uses the whole cluster without too much scheduling work.

ExperiencedMost askedScenarioFree with sign-in
Answer

How would you fix a job that creates thousands of small files?

Small files overload the file system and slow down later reads. Fix it when writing, and with compaction.

ExperiencedMost askedFree with sign-in
Answer

How does fault tolerance work in Spark?

Spark tracks lineage, which is the chain of transformations that built each partition. If a partition or executor is lost, Spark recomputes only the lost partitions from the source.

ExperiencedMost askedFree with sign-in
Answer

Explain Spark Structured Streaming. What are triggers, watermarks and checkpoints?

Structured Streaming treats a stream as a table that keeps growing. It runs the same DataFrame API step by step in micro-batches.

ExperiencedMost askedScenarioFree with sign-in
Answer

How do you size a Spark cluster and choose executor memory and cores?

Start from the workload and the node size of the cluster. Then tune using the Spark UI.

ExperiencedMost askedScenarioFree with sign-in
Answer

A join between two large tables is failing with executor lost errors. What do you do?

First find out why executors die. Then reduce the pressure.

ExperiencedMost askedFree with sign-in
Answer

What is a pandas UDF and when do you use it?

A pandas UDF (vectorized UDF) gets and returns pandas Series or DataFrames in batches, using Apache Arrow. This avoids serializing row by row.

ExperiencedMost askedFree with sign-in
Answer

What is the difference between Spark deploy modes: client and cluster?

The mode decides where the driver runs.

ExperiencedMost askedScenarioFree with sign-in
Answer

How would you process a 1 TB daily file load incrementally instead of reprocessing everything?

Process only new or changed data, and make the job idempotent (running it twice gives the same result).

ExperiencedMost askedFree with sign-in
Answer

What are Delta Lake, Iceberg and Hudi, and why are they used on top of Parquet?

They are open table formats. They add a transaction log and metadata on top of Parquet files in object storage.

ExperiencedMost askedScenarioFree with sign-in
Answer

How do you debug a PySpark job that works locally but fails on the cluster?

The difference is usually the environment, the data size, or serialization.

ExperiencedMost askedFree with sign-in
Answer

How do you write a PySpark DataFrame to a relational database such as PostgreSQL?

Use the JDBC writer, with the driver jar on the classpath.

Python for Data

ExperiencedMost askedScenario
Answer

How do you process a CSV file too large to fit in memory with pandas?

Read it in chunks. Aggregate or write out each chunk. Never hold all the data at once.

import pandas as pd
totals = {}
for chunk in pd.read_csv("big.csv", chunksize=500_000, usecols=["region", "amount"],
                         dtype={"region": "category"}):
    part = chunk.groupby("region")["amount"].sum()
    for k, v in part.items():
        totals[k] = totals.get(k, 0) + v
print(totals)

Also do these things. Load only the columns you need (usecols). Choose smaller dtypes. Parse dates explicitly. Convert the file to Parquet once. If the data keeps growing, move to DuckDB, Polars (lazy mode), Dask or Spark.

What they are checking: Practical large-file handling

ExperiencedMost asked
Answer

How would you write a pandas DataFrame to a relational database?

Use DataFrame.to_sql with a SQLAlchemy engine. Write in chunks.

import pandas as pd
from sqlalchemy import create_engine
engine = create_engine("sqlite:///demo.db")
df = pd.DataFrame({"id": [1, 2], "amt": [10.5, 20.0]})
df.to_sql("sales", engine, if_exists="append", index=False, chunksize=10_000, method="multi")

Notes: if_exists can be fail, replace or append. to_sql only inserts rows. For upserts (update or insert), load into a staging table. Then run INSERT ... ON CONFLICT or MERGE in SQL. For large PostgreSQL loads, COPY through psycopg is much faster. Keep credentials in environment variables or a secrets manager.

What they are checking: Loading to a database

ExperiencedMost askedScenario
Answer

How do you validate data quality in a Python pipeline?

Validate at the edges: right after reading and right before writing. Check the schema, nulls, uniqueness, ranges and links between tables (referential integrity). Fail the job, or set bad rows aside.

import pandas as pd
df = pd.DataFrame({"id": [1, 2, 2], "age": [25, -3, 40]})
errors = []
if df["id"].duplicated().any():
    errors.append("duplicate ids")
bad = df[~df["age"].between(0, 120)]
if not bad.empty:
    errors.append(f"{len(bad)} rows with invalid age")
print(errors)

Useful libraries: Pandera, Great Expectations, Pydantic (row by row) and dbt tests. Good practice: write rejected rows to a quarantine table with a reason. Track row counts in and out. Alert when the failure rate crosses a limit. Do not drop data silently.

What they are checking: Reliability mindset

ExperiencedMost askedScenarioFree with sign-in
Answer

How do you make a Python data pipeline idempotent?

Idempotent means that running a job twice leaves the same final state as running it once.

ExperiencedMost askedScenarioFree with sign-in
Answer

How would you speed up a slow pandas script?

Profile first (%timeit, cProfile). Then fix the biggest cost.

ExperiencedMost askedScenarioFree with sign-in
Answer

A nightly Python script that loads data into the database ran twice and created duplicates. How do you fix it and prevent it?

Fix the data first. Then change the design so a rerun does no harm.

ExperiencedMost askedFree with sign-in
Answer

How can you reduce the memory usage of a pandas DataFrame?

Use smaller dtypes and load less data.

  • Make numbers smaller: pd.to_numeric(s, downcast="integer").
  • Turn strings with few distinct values into category.
  • Use nullable or string[pyarrow] dtypes for text.
  • Read only the columns you need with usecols.
  • Delete intermediate DataFrames and read in chunks.
ExperiencedMost askedScenarioFree with sign-in
Answer

How do you do an upsert into a database from Python?

Load the batch into a staging table. Then merge it into the target table with one SQL statement, inside a transaction.

ExperiencedMost askedFree with sign-in
Answer

What is the difference between apply, map and vectorized operations in pandas?

Vectorized operations run in compiled code on whole columns. They are the fastest. map and apply call a Python function for each element or row, so they are much slower.

ExperiencedMost askedFree with sign-in
Answer

How do you use multiprocessing in Python for data processing, and how is it different from threading?

Because of the GIL, threads do not run Python code in parallel. So use threads for I/O-bound work and processes for CPU-bound work.

ExperiencedMost askedFree with sign-in
Answer

How do you list all objects under an S3 prefix in boto3 when there are more than 1000?

Use a paginator. It follows the continuation tokens for you.

ExperiencedMost askedScenarioFree with sign-in
Answer

How do you handle API pagination and rate limits when extracting data with Python requests?

Loop until there is no next page. Reuse one session. Respect rate limits. Retry temporary errors with backoff (wait longer after each failure).

ExperiencedMost askedScenarioFree with sign-in
Answer

How do you merge two large DataFrames efficiently and avoid a memory explosion?

Make both sides smaller first. Then merge. Watch out for duplicate keys.

ExperiencedMost askedFree with sign-in
Answer

How do you work with dates and time zones in pandas?

Parse to datetime. Make the time zone explicit. Convert only at the edges.

ExperiencedMost askedFree with sign-in
Answer

Explain how you would log and handle errors in a Python ETL job.

Use the logging module with levels. Catch specific exceptions. For each error, decide whether to retry, skip or fail.

ExperiencedMost askedScenarioFree with sign-in
Answer

How do you implement an incremental extract in Python using a watermark?

Save the highest value of a column that only grows (such as updated_at or an id) from the last successful run. Then query only the rows beyond it. This saved value is called a watermark.

ExperiencedMost askedFree with sign-in
Answer

What are decorators and context managers, and where do you use them in pipelines?

A decorator wraps a function to add behavior. A context manager handles setup and cleanup around a with block.

ExperiencedMost askedFree with sign-in
Answer

How do you unit test a data transformation function?

Write transformations as pure functions. They take a DataFrame and return a DataFrame. Then test them with small hand-made inputs using pytest.

ExperiencedMost askedFree with sign-in
Answer

How do you process files concurrently when downloading many objects from S3?

Downloads wait on the network (I/O-bound), so use a thread pool.

Airflow

ExperiencedMost asked
Answer

What is the difference between executors in Airflow: Local, Celery and Kubernetes?

The executor decides how tasks are run.

ExecutorHow it runs tasksGood for
SequentialOne at a time, uses SQLitetesting only
LocalParallel processes on the scheduler machinesmall setups
CeleryPool of long-running workers via Redis/RabbitMQsteady load, many short tasks
KubernetesA new pod for each taskisolation, bursty load, per-task resources

Celery starts tasks fast, but you must manage the workers all the time. Kubernetes gives clean isolation and autoscaling. But each task pays the pod start-up time. There is also CeleryKubernetes, which uses both. Recent versions can also use several executors at once.

What they are checking: Can you choose the right way to scale?

ExperiencedMost asked
Answer

How does Airflow scheduling work with start_date and schedule? Why does a DAG run after the interval ends?

A DAG run covers one data interval. It starts only after that interval has ended.

Example: a @daily DAG has the data interval 2025-10-01 00:00 to 2025-10-02 00:00. It starts at 2025-10-02 00:00. Its logical date (ds) is 2025-10-01, the start of the interval. This is because the run processes the data of that interval.

  • start_date: the start of the first interval. Nothing runs before it.
  • schedule: a cron string, a preset (@daily) or a timetable.
  • Templated values such as {{ data_interval_start }} and {{ ds }} help tasks fetch the right slice of data.

So a new DAG with today's start_date seems not to run. The first interval has not finished yet.

What they are checking: This is one of the most confusing Airflow ideas. Can you explain it clearly?

ExperiencedMost asked
Answer

What does it mean for an Airflow task to be idempotent and how do you achieve it?

An idempotent task gives the same result if you run it once or many times for the same logical date. So retries and backfills are safe.

  • Use {{ ds }} or the data interval as a parameter. Never use datetime.now().
  • Overwrite the partition for that date, or use upsert/MERGE. Do not just append.
  • Write to a temporary place, then swap it in one step (atomic).
  • Delete and insert the date's data in one transaction.
  • Avoid side effects that cannot be repeated, or protect them with a check.
DELETE FROM fact_sales WHERE load_date = '{{ ds }}';
INSERT INTO fact_sales SELECT * FROM stage WHERE load_date = '{{ ds }}';

What they are checking: Do you know the key design rule?

ExperiencedMost askedScenarioFree with sign-in
Answer

Your DAG is not showing up in the Airflow UI. What do you check?

Work from the file toward the scheduler.

ExperiencedMost askedScenarioFree with sign-in
Answer

A DAG is enabled but its scheduled runs are not starting. What could be wrong?

Check these in order:

ExperiencedMost askedScenarioFree with sign-in
Answer

Tasks are stuck in the 'queued' state. How do you troubleshoot it?

Queued means the scheduler gave the task to the executor, but no worker has started it.

ExperiencedMost askedFree with sign-in
Answer

What are best practices for writing Airflow DAGs?

  • Keep top-level DAG code light. No API calls, DB queries or heavy imports at parse time.
  • Make tasks idempotent and atomic. Use logical dates and templates.
  • Use small tasks with clear limits, not one giant function.
  • Keep Airflow as the orchestrator. Push heavy work to Spark, warehouses or containers.
  • Keep...
ExperiencedMost askedScenarioFree with sign-in
Answer

How would you design a daily pipeline: extract from an API, load to S3, transform with Spark, load to a warehouse?

Use four idempotent tasks, keyed on the logical date. Airflow orchestrates them, and other systems do the work.

ExperiencedMost askedScenarioFree with sign-in
Answer

You need to rerun a failed pipeline for the last 30 days after fixing a bug. How do you do it safely?

Use a backfill, or clear the past runs, with limits, on idempotent tasks.

ExperiencedMost askedFree with sign-in
Answer

What are trigger rules in Airflow?

A trigger rule decides when a task runs, based on the states of its upstream tasks. The default is all_success.

ExperiencedMost askedFree with sign-in
Answer

What is dynamic task mapping in Airflow?

Dynamic task mapping (Airflow 2.3+) creates a changing number of task instances at runtime. The number depends on the output of an upstream task. You use expand.

ExperiencedMost askedScenarioFree with sign-in
Answer

Tasks are stuck in the 'running' state but nothing is happening. What do you do?

The task process may have died without telling Airflow. Or it may be waiting on something forever.

ExperiencedMost askedFree with sign-in
Answer

How do you test an Airflow DAG?

Test in layers:

ExperiencedMost askedScenarioFree with sign-in
Answer

A DAG takes too long to parse and the scheduler is slow. How do you fix it?

Parse time is the time spent running your DAG files. So cut the work done at module level.

ExperiencedMost askedFree with sign-in
Answer

Explain the concurrency settings: parallelism, max_active_runs and max_active_tasks.

  • parallelism (core config): the most task instances that can run at once in the whole installation.
  • max_active_tasks (per DAG): the most task instances that can run at once for one DAG, across its runs.
  • max_active_runs (per DAG): the most DAG runs at once. It helps with backfills and stops runs from overlapping.
  • max_active_tis_per_dag (per task): the limit for one task across runs.
  • worker_concurrency (Celery): tasks for each worker.
  • Pools: a limit for each resource.
ExperiencedMost askedFree with sign-in
Answer

What is the difference between PythonOperator and a custom operator or hook? When do you write your own?

A hook is a reusable way to talk to an outside system (connection handling, API calls). Examples are S3Hook and PostgresHook. An operator is a task template. It usually uses a hook to do its job.

ExperiencedMost askedFree with sign-in
Answer

What are deferrable operators and the triggerer?

Deferrable operators give a long wait to the triggerer. This is a background (async) process that runs many waiting triggers in one event loop. While the task is deferred, it frees its worker slot. So thousands of waits cost almost nothing.

ExperiencedMost askedFree with sign-in
Answer

What happens if the scheduler or a worker dies during a task?

The scheduler and workers are separate. The state lives in the metadata database. So a restart continues the work.

ExperiencedMost askedFree with sign-in
Answer

What is the Airflow metadata database and what problems can it cause?

It stores DAGs, runs, task instances, XComs, connections, variables and references to logs. It is the single source of truth, so everything depends on it.

ExperiencedFree with sign-in
Answer

What is the difference between schedule, schedule_interval and timetable?

schedule_interval was the older argument. It took a cron string, a preset or a timedelta. In Airflow 2.4+, the single schedule argument replaces it. schedule accepts a cron expression, a preset like @daily, a timedelta, a list of datasets, or a Timetable object. Custom timetables handle rules that cron cannot write, such as 'every business day' or odd calendars.