← Snowflake Interview Insights

Snowflake·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Snowflake SWE interview with a pretty meaty coding question around virtual functions and building out a SQL engine. Not a typical leetcode grind, more of a design-meets-implementation problem that caught me a bit flat-footed.

Questions Asked (1)

Q1

Using virtual functions, design and implement a database SQL engine that supports a set of query operators.

System DesignTechnical Trade-offsAlgorithms & Data Structures
Author's notes

This one had more depth than I expected.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the scope: a simplified SQL engine that supports basic operators like scan, filter, project, and join. Then design an abstract Operator base class with a virtual next() method, and implement concrete operators that form a tree (the query plan). Discuss how this design enables extensibility and aligns with database engine architecture.

Pro tip: Mention that this is essentially the Iterator model (Volcano model) used in real databases like Snowflake, and highlight how virtual functions enable polymorphism for operator composition. Also, briefly discuss trade-offs like performance overhead of virtual calls and potential optimizations.

1. Clarify Requirements and Scope

Ask clarifying questions to define the subset of SQL to support (e.g., SELECT, WHERE, JOIN) and the expected interface (e.g., next() returning tuples). Confirm assumptions about data storage and execution model.

2. Design the Operator Interface

Define an abstract base class Operator with a pure virtual method next() that returns the next tuple or a sentinel. Optionally include open() and close() methods for setup and teardown.

3. Implement Concrete Operators

Create classes for Scan, Filter, Project, and Join that inherit from Operator. Each implements next() to produce tuples, possibly pulling from child operators.

4. Compose Operators into a Query Plan

Show how operators are linked in a tree (e.g., Filter has a child Scan). Explain how the root operator's next() drives execution, pulling tuples through the tree.

5. Discuss Extensibility and Trade-offs

Highlight how new operators can be added without modifying existing code (open/closed principle). Discuss performance considerations like virtual call overhead and batch processing as an optimization.

Key Points to Mention

  • Virtual functions enable polymorphism, allowing the query executor to treat all operators uniformly.
  • The Iterator (Volcano) model: each operator implements next() to return one tuple at a time.
  • Operator tree composition: parent operators pull from children, forming a pipeline.
  • Extensibility: new operators (e.g., Sort, Aggregate) can be added by subclassing Operator.
  • Trade-offs: virtual function overhead vs. flexibility; potential for vectorized execution to amortize costs.
  • Real-world relevance: similar to execution engines in Snowflake and other databases.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.