AWS Training
Modules Listen Certification

← Senior Spark Technical Lead (Scala, Python) — Role Review

STL Interview questions

Read these out loud. Under 90 seconds each. For a lead role the scoring pattern shifts: a senior engineer is scored on the mechanism; a lead is scored on the mechanism, then the decision, then how the team learns it. If your answer ends at the mechanism, you have answered for the job below the one you're applying for.

Every technical figure here is the one cited in the lesson named beside it, verified against Apache Spark 4.3.0 on 2026-11-22. The leadership answers are a way to structure your own experience — swap in a real project wherever an answer says "for example".


Warm-up

Q. Which Scala version does Spark use, and why does it matter?

Spark four is built on Scala two thirteen, and only two thirteen — two twelve was dropped in four point oh. It matters because Scala isn't binary compatible across those versions, so your application and every Scala library on the classpath has to be built for the same one. That's what the underscore two thirteen suffix on an artifact means. So a move from Spark three five to four isn't just a Spark upgrade for a Scala team. It's a rebuild of everything, and the first job is checking that every dependency actually publishes a two thirteen build. (Lesson 1.)

Q. What's the difference between a DataFrame and a Dataset?

In Scala a DataFrame literally is a Dataset of Row — it's a type alias. A typed Dataset carries a case class, and an encoder maps that class to Spark's internal format. Python doesn't have the typed API at all. What you buy with the type is compile-time checking: a misspelled field doesn't compile. What you pay is that a lambda over those objects is opaque to the optimizer. I ran the same filter both ways — the column version pushed the predicate into the Parquet scan, the lambda version pushed nothing. So my rule is: types at the edges for safety, column expressions in the middle where the optimizer needs to see. (Lesson 2.)

Q. Is Scala faster than Python on Spark?

For DataFrame and SQL code, no — and I can show it. The same aggregation in both languages gives an identical physical plan, because the language only builds the plan; the engine runs it. The difference appears only where your own code runs on rows — U D Fs. A Scala U D F runs inside the executor. A Python U D F ships rows to a Python worker and back. So the honest answer is: it depends how much of the job's time is inside a U D F, and for most pipelines that's very little. (Lesson 3.)

Q. What is adaptive query execution, in one breath?

Spark re-plans between stages using the real sizes of the shuffle output, instead of estimates. Three things come out of that: it coalesces small shuffle partitions, it can switch a join strategy, and it can split a skewed partition. It's been on by default since three point two. The part people get wrong is assuming that enabled means it did something — each of those has its own thresholds. (Lesson 4.)

Q. What changed in Spark 4 that a team actually feels?

A N S I mode is on by default. So an integer overflow or a bad cast that used to quietly return a wrong number or a null now raises an error. Then the platform floor: Scala two thirteen only, Java seventeen, and newer Python. Those are the two things that break on day one. The features — VARIANT, the Python data source A P I, the new streaming state A P I — you adopt when you choose to. The defaults you get whether you chose to or not. (Lesson 6.)

Q. How do you review a Spark pull request?

In order of blast radius. First, anything that gives a wrong answer silently — a join on a key that isn't unique, an overwrite that deletes partitions, null handling. Second, anything that kills the job at real volume — collect, a window with no partition. Third, anything that's just slow. And every comment names the mechanism, not a rule. "This lambda hides the predicate from the optimizer, here's the plan" teaches something. "Don't use lambdas" doesn't. (Lesson 5.)


Depth

Q. A job fails with "Task not serializable". Walk me through it.

Spark serializes the function you pass to an operation and sends it to the executors. If that function reads a field of the enclosing class, it captures the whole object, and if the object isn't serializable you get this error before a single task runs. So I read the serialization stack — the first line names the class it couldn't serialize. The simplest fix, and it's the one the Spark guide gives, is to copy the field into a local value and use that in the lambda. If the thing captured is a client or a connection, it goes in a singleton object or behind a transient lazy val, so each executor builds its own. (Lesson 2.)

The follow-up they ask next: "Why not just make the class Serializable?" — Because it only moves the problem. I've run it: the class serialized, and then the failure named the non-serializable member inside it. And even when it works, you're now shipping the whole object to every task.

Q. Your typed Dataset job has run for a month and failed last night with a null error. What happened?

Almost certainly a null arrived in a column that maps to a primitive field — a Double or a Long in the case class. The conversion to the case class is checked when you build the plan, for names and types. Nullability isn't. So it passes for a month, and fails inside a task the first night the source sends a null. The fix is to declare that field as an Option. The lead-level fix is a review rule: any field fed by a source we don't control is an Option until someone proves otherwise. (Lesson 2.)

The follow-up: "How would you have caught it earlier?" — A unit test with a null in every nullable source column. It's a one-row test and it fails in seconds on a laptop.

Q. What is the default behaviour of a Python UDF today, and what does that change?

Since Spark four point two, a plain Python U D F uses Arrow to move the data, by default. It still runs row by row on ordinary Python objects — Arrow changed the transport, not the computation. A pandas U D F is the one that's actually vectorised. Two consequences. One: the ordering I'd expect is built-in fastest, then pandas, then Arrow Python, then pickled Python. Two — and this is the one that bites — Arrow changes type coercion, so a U D F can return different results after an upgrade without any code change. That goes on the upgrade test list. (Lesson 3.)

The follow-up: "Is that true on your cluster?" — I'd check rather than assume. On the twenty-second of November the newest A W S runtimes were on the four point one line, which is before that default changed. I'd read the config on the runtime.

Q. AQE and skew join are both on, and one task is still enormous. Why?

Because enabled isn't triggered. A partition is only treated as skewed if it's more than five times the median and over two hundred fifty-six megabytes — both, with the defaults. I reproduced this: a hot partition of a hundred eighty-five megabytes, ninety percent of the rows on one key, and A Q E did nothing about the skew. It just coalesced everything down to two tasks. Past the threshold, the plan changed. So I look for the evidence in the final plan — the join says skew equals true. If those words aren't there, it didn't happen. (Lesson 4.)

The follow-up: "So you'd lower the threshold?" — Maybe, but I'd ask first whether the skew is in the data or in the join. A hot key that's a null or a default value is a data problem — filter it or handle it separately. Lowering a threshold to split a partition of garbage is tuning the symptom.

Q. What does overwrite do to a partitioned table on a re-run?

With the default, static mode, it deletes every partition under that path and writes only what's in this run. So a daily job that overwrites with one day of data leaves you one day. I've watched three partitions become one. Dynamic mode replaces only the partitions present in the data, and you can set it per write. Append isn't the fix either — a retry doubles the rows. For me, "what happens if this runs twice" is a question every Spark pull request has to answer in its description. (Lesson 5.)

The follow-up: "And on Iceberg or Delta?" — I'd say I haven't verified that behaviour on the table format in question and I'd test it before answering. Table formats have their own overwrite semantics, and guessing about a delete is how you lose data.

Q. An operator passes a config at submit time and the job ignores it. Why?

Because the job set the same key in code, and code wins. The precedence is: what's set on the Spark conf in the application, then the flags on spark-submit, then the defaults file. So anything hard-coded in the session builder can't be changed without a code change and a deploy. My rule for the team: logic in code, tunables at submit time. And some settings — driver memory in client mode — can't take effect from code at all, because the driver J V M has already started. (Lesson 5.)

The follow-up: "What do you allow in code, then?" — Things the job's correctness depends on. If the job is wrong without dynamic partition overwrite, that belongs with the write, as a write option, where a reviewer can see it.

Q. How do you stay current with Spark?

Three sources, on a schedule. The release notes tell me what was added. The migration guide tells me what changed — and that's the one people skip. And for where the project is heading, the improvement proposals, which are JIRA tickets labelled S P I P and discussed on the dev list. Then one more list that matters more than the rest: what my platform actually runs. Open source is at four point three; Glue and the Spark four runtime on E M R are at four point one. So for every feature I read about, the second question is "when can we use it", and I know where to look that up. (Lesson 6.)

The follow-up: "Give me an example of something you'd only find in the migration guide." — Four point three renamed an adaptive-execution rule. If you'd excluded the old name in config, Spark silently ignores a name it doesn't recognise — so your exclusion stops working and nothing fails.

Q. Scala or Python for a new pipeline?

It depends, and here's what I'd ask you. Who maintains it in a year — what does the team actually write well? What's the existing codebase and its shared libraries? Is there a library we need that only exists on one side? What's the latency target — because some of the newest streaming capability, like stateful processing in real-time mode, is J V M only in four point three. And is any real time spent in row-level custom code? If the answers are "a Python team, batch, mostly DataFrame operations", it's Python, and performance isn't the reason to argue. If it's a low-latency stateful stream or a custom connector, it's Scala. What I won't do is let one pipeline be half and half. (Lesson 3.)

The follow-up: "The team is split and both sides feel strongly." — Then I take the argument away from preference. Same plan for DataFrame code — I'll show them the diff. Shared business logic goes in S Q L functions both sides can call. And each pipeline has one language and one owner.


Leading — the lines that are most of the posting

Q. Tell me how you lead a technical team day to day.

Three things I hold myself to. I make the standard visible — a review checklist, a definition of done, a way we investigate performance — so quality doesn't depend on who reviewed it. I stay close enough to the code to be useful: I review, and I pair on the hard problems, but I try not to be the person who writes the critical path, because then I'm the bottleneck and nobody else grows. And I make decisions explicit — what we chose, what we rejected, and why — in writing, so the decision outlives the meeting. For example… (give one real decision and what it cost you).

Q. A junior engineer's job is slow and they ask you to fix it. What do you do?

I don't fix it. I ask for evidence, in an order: which stage is slow, what the task time distribution looks like — the max against the median — and whether there's spill. Usually by the third question they've found it themselves. If they change a config, I ask for one change at a time, with the metric before and after. It's slower than me fixing it — the first time. The second time, they don't ask.

Q. How do you gather requirements for a data pipeline from stakeholders who aren't technical?

I ask about the decision, not the data. What will you do differently when you have this number? How wrong can it be before that decision changes? How late can it be? Those three give me correctness, tolerance, and freshness — which is most of the design. Then I write back a one-page scope in their language: what's in, what's explicitly out, what "done" looks like, and the one or two things I need from them. The explicit "out" list is the part that prevents scope arguments in week six.

Q. A stakeholder wants a feature from the newest Spark release, next sprint.

I'd check before I answered. The question isn't whether Spark has it — it's whether our runtime does. I'd find which release added it and what version our platform actually runs. If there's a gap, I give them the real options: wait for the managed runtime, run a newer Spark ourselves and own the operations, or meet the need another way. With a cost on each. What I don't do is say yes because the release notes said so.

Q. Two senior engineers disagree about a design and it's stalling the project.

I get the disagreement written down as a decision with criteria — what are we optimising for, and what would make each option the wrong one. Most stalemates are two people optimising for different things without saying so. If evidence can settle it cheaply, we time-box a spike. If it can't, I decide, I say why, and I write down what would make me revisit it. Then I make sure the person whose option lost gets to own part of making the chosen one work.

Q. How do you mentor, concretely?

Through the work, mostly in review. A comment that names the mechanism and links the doc is mentoring; a comment that says "change this" is just editing. Beyond that: a short written write-up after every real incident or investigation, shared with the team, and I rotate who presents it. And I hand over ownership in increasing size — a function, then a job, then a pipeline — and stay available without taking it back.

Q. How do you make sure "best practices" are actually followed?

By making the right way the easy way, and checking automatically what can be checked. Formatting and linting run on every pull request, so nobody argues about them. Tests run on local Spark in C I. Then a short definition of done that a human checks: there's a test, someone has looked at the plan, a re-run is safe, there's an alarm. If a rule isn't automated and isn't on that list, it's a preference, and I don't pretend it's a standard.


Design

Prompt. You're leading a team of six — four strong in Python, two in Scala — taking over a nightly batch platform of about sixty PySpark jobs on Spark 3.5. The business also wants a new low-latency stream scoring events within a second. Lay out your first ninety days.

Questions first. What's breaking today — failures, lateness, wrong numbers? What does "within a second" mean — end to end, at what percentile, and what happens if it's two? What runtime are we on, and who operates it? Is there a test suite? I'd want those answers before designing anything.

The trade-off. There are three pulls: stabilise what exists, upgrade it, and build the new thing. Doing all three at once with six people is how none of them finishes. And the stream has a real language constraint — the newest low-latency stateful processing is J V M only on the current release, and the managed runtimes are a couple of releases behind open source, so I have to check what we can actually run before I promise sub-second.

The choice. First thirty days: evidence and guardrails. Event logs on everywhere, a review checklist, a definition of done, tests around the ten jobs that matter most. No rewrites. Days thirty to sixty: the upgrade path, as a rehearsal — read the migration guide, pin the behaviour-restoring configs, run the test suite on the new version, shadow-run and diff outputs. I'd expect A N S I mode to surface real bugs and I'd tell stakeholders that in advance, because errors appearing during an upgrade look like the upgrade's fault. In parallel, the two Scala engineers prototype the stream on the runtime we can really get, and I pair a Python engineer with them so the knowledge isn't in two heads. Days sixty to ninety: migrate in batches, and take a go or no-go on the stream's latency with measured numbers.

The batch jobs stay in Python. Same plans either way; rewriting sixty jobs buys nothing.

What I'd monitor. Per job: duration against its own history, failures, and output row counts against yesterday. For the upgrade: output diffs between old and new. For the stream: end-to-end latency at the percentile we agreed, and lag. For the team: whether review comments are getting shorter.

(Lessons 3, 4, 5, 6. The version facts are the ones in lesson 6's AWS table — re-check them before the interview.)


Debug

"A job that took twenty minutes yesterday took three hours today. Same code. What do you check?"

  1. Is it the same job? Same code version, same config, same input size. Input volume first — a backfill or a late file explains most of these.
  2. Waiting or working? Scheduler delay and how many executors it actually got. A busy cluster is not a slow job.
  3. Which stage. Compare stage durations with yesterday's run from the event log — which is why event logging has to be on before the incident; it's off by default.
  4. Task distribution in that stage. Max against median, for duration and shuffle read. One huge task means skew: find the key.
  5. Spill and GC on that stage.
  6. The plan actually executed — the SQL tab, not a fresh explain. Did a broadcast join become a sort-merge because a table crossed the threshold? Did partition pruning stop?
  7. Only then the code and the config. One change, measured, with the before and after written down.

"A Scala job passes every test and fails in production with a serialization error on one executor."

  1. Read the first line of the serialization stack: which class.
  2. Find the lambda that reads a field or method of that class.
  3. Ask why tests passed: was it only run in the shell or local mode with different class loading? Lesson 2 found one fix that behaved differently in spark-shell than in a compiled jar — reproduce in compiled code.
  4. Fix at the capture: local val, or an object, or @transient lazy val for a client.
  5. Add a test that runs the transformation through a real action on a local session — building the plan is not enough.

"After an upgrade to Spark 4, numbers in a report changed slightly. No errors."

  1. Diff outputs between the old and new run to find which columns and rows.
  2. Check the migration guide's changed defaults against what those columns use — timestamp parsing, JDBC type mappings, casts.
  3. Check whether ANSI was switched off to get the upgrade through. If so, turn it on in a test run and see what raises — the old numbers may be the wrong ones.
  4. If Python UDFs are involved and the runtime is 4.2 or later, check Arrow's type coercion.
  5. Report which side was wrong, with the rows. Do not "restore the old numbers" before you know.

Red flags

"Scala is faster than Python, so performance-critical jobs should be Scala." Sounds senior. It's false for DataFrame code — identical plans — and it tells the interviewer you'd spend a team's quarter on a rewrite without measuring.

"I'd turn on Kryo." For what? Datasets use encoders, not Kryo, and it doesn't fix closure serialization. Offered as a reflex, it signals a bag of configs instead of a diagnosis.

"AQE handles skew automatically." Only past both thresholds. Saying this without the condition shows you've read the feature list and never checked a plan.

"I'd increase executor memory." As a first move, it's tuning without evidence. The lead answer starts with which stage and what the task distribution looks like.

"We just turned ANSI mode off for the upgrade." As a temporary pin with a plan to remove it, fine. As the end state, you've chosen silent wrong answers over loud ones — say which it is.

"I'd rewrite it myself to be safe." For a lead role this loses the offer faster than any technical mistake. The posting has eight responsibilities and none of them is "write the code".

"I stay current by reading blogs." Name the sources and the method: release notes, migration guide, proposals, and what your runtime actually ships.

"Best practice says…" Whose, and why? A lead who can't give the mechanism is enforcing taste.