Skip to main content
InterviewHubPRO
Section Overview
Q11

Question 11 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

22%
Apache Spark Big Data (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

How does the Catalyst Optimizer optimize Spark SQL queries?

senior LevelSystem DesignDatabases & SQL

In Simple Words: Catalyst is Spark's rule-based and cost-based query optimization engine. It operates in 4 phases:

  1. Analysis: Resolves table and column names against the Catalog to produce an Analyzed Logical Plan.
  2. Logical Optimization: Applies rule-based optimizations: Predicate Pushdown (filters pushed to storage source) and Column Pruning (reading only queried columns).
  3. Physical Planning: Generates multiple physical execution strategies and picks the cheapest one using a Cost-Based Optimizer (CBO).
  4. Code Generation (CodeGen): Generates optimized Java bytecode on-the-fly for whole-stage execution.