Add logical plan between AST and execution
We currently translate the AST directly to a physical plan. Having an in-between logical plan will allow us to run optimizers before the query is executed.
The logical plan would have a one to one mapping with the AST and will contain the parameters of each AST node. Query optimizers can then transform the logical plan based on predefined heuristics. One example would be optimizing series selects in binary operations so that we do as few network calls as possible.
Finally, we would build the physical plan from the optimized logical plan instead doing it from the AST directly.

As discussed on Slack, https://github.com/thanos-io/thanos/issues/4407 this is something we can support when having the logical plan and optimizer.
I will close this as we already support logical plan