I know impala re-formulates the query to run in an optimizated way. Lets say I have a query
select location, zipcode, car_model from (
select location, zipcode, car_model, car_color from table1
select location, zipcode, car_model, car_color from table2)
You can see car_color is being queried on inner tables but not required on outer select.
Does Query optimization handle not querying extra columns ?. Is there any command to check this.
Yes the Impala planner will drop unused columns at various points in the plan, often in aggregations or sorts. It's not easy to precisely enumerate when it will or won't happen, but it's definitely a thing that the planner will do in many cases.
You can look at row-size= in the extended explain plans (explain_level>= 2) to get an idea of the size of the row at each point in the plan.
I think in your specific query it should notice that the column car_color isn't being used. I didn't test. You could confirm by adding/removing unused columns and seeing if row-size changes in the explain plans.