Skip to main content
InterviewHubPRO
Section Overview
Q36

Question 36 of 50

Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

72%
Apache Spark Big Data (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

Catalyst Optimizer Deep Dive: Analysis, Logical Optimization, Physical Planning, and Cost-Based Optimizer (CBO).

senior LevelPerformance

In Simple Words: The Catalyst Optimizer is Spark's query compiler that transforms DataFrame code and SQL into highly optimized bytecode:

  1. Analysis: Resolves table and column names against the Catalog / Metastore.
  2. Logical Optimization: Applies rule-based transformations:
    • Predicate Pushdown: Moves filters as close to the data source as possible to minimize disk I/O.
    • Projection Pruning: Discards unused columns early in the plan.
  3. Physical Planning: Generates multiple physical execution strategies (e.g. BroadcastHashJoin vs SortMergeJoin) and uses the Cost-Based Optimizer (CBO) with table statistics (row counts, histograms) to choose the cheapest plan.
  4. Code Generation (Tungsten): Compiles the optimal physical plan into compact Java bytecode executed at runtime.