Bigdata SQL: apache hive Query Compiler p2

The Physical Plan Generator takes the optimized plan generated previously and translates this to the actual implementation—in terms of what is being used as the underlying engine to satisfy the query, whether it is plain MapReduce, Tez Engine, or Spark Engine. It converts the optimized plan to operators that will actually implement the query. The transformation of an SQL query to MapReduce happens here. A complex SQL query can involve multiple MapReduce stages, and the operators to shuffle the data between the stages, etc., are added here, in this plan optimization stage.
The Physical Plan Optimizer is the final level of optimization. It applies another level of optimization, to ensure that the query uses the least amount of resources. It is here that the
best algorithm to perform the join is decided—whether to apply Broadcast join or Hash join or Shuffle join or a Map Join at the implementation layer, based on the data set sizes, etc.
Finally, at the execution stage, the whole optimized plan is written to an XML file called plan.xml , which the MapReduce engine within Hive takes and submits the query to the Hadoop scheduler.