Open skyzh opened 9 months ago
The reason for the repeat is that as
is eliminated at binder stage and doesn't exist in the plan. In egg-based planner, common expressions always share the same node. So I didn't introduce the as
node in order not to make things complicated.
I think there are 2 possible solutions for this issue:
Projection { exprs: [ $0 ] }
└── Projection { exprs: [ + { lhs: v1, rhs: v1 } as $0 ] }
...
as
variable information by introducing as
node to the planner. However, this may break some optimization rules and lead to unknown behavior.The reason for the repeat is that
as
is eliminated at binder stage and doesn't exist in the plan. In egg-based planner, common expressions always share the same node. So I didn't introduce theas
node in order not to make things complicated.I think there are 2 possible solutions for this issue:
- Resolve common expressions from child nodes and assign temporary variables for them in EXPLAIN. The output would be like:
Projection { exprs: [ $0 ] } └── Projection { exprs: [ + { lhs: v1, rhs: v1 } as $0 ] } ...
- Keep
as
variable information by introducingas
node to the planner. However, this may break some optimization rules and lead to unknown behavior.
It looks like option 1 might be simpler
currently, if we have a query like this, the output is kind of a little bit hard to decipher, as we repeat the same expression twice in the explain format.
probably we should have something like,