[SPARK-3969][SQL] Optimizer should have a super class as an interface.

Some developers want to replace `Optimizer` to fit their projects but can't do so because currently `Optimizer` is an `object`.
It is confusing to use the same name for both. 
Will this mean an API change?