924060929 commented on PR #63366:
URL: https://github.com/apache/doris/pull/63366#issuecomment-4708136408

   @morrySnow re: "why don't you impl it before translation and after 
post-process in Nereids?"
   
   Local-exchange planning needs two inputs that only exist **after translation 
+ distribute**, not on the Nereids physical plan:
   
   1. **PlanNode-level info** — `AddLocalExchange` walks the translated 
`PlanNode` / `PlanFragment` tree via `PlanNode.enforceAndDeriveLocalExchange`, 
using per-node things like `isSerialNode()` / `isSerialOperatorOnBe()`, the 
distribute-expr lists serialized to BE thrift, the fragment sink type, etc. 
Those are the legacy `PlanNode` structures produced by the translator — they 
don't exist on the Nereids physical operators.
   
   2. **Instance counts** — whether to insert an LE (and the fan-out width) 
depends on the per-BE instance count: `addLocalExchange` skips fragments where 
`maxPerBeInstances <= 1` (mirroring BE's `_num_instances <= 1` no-op), and the 
PASSTHROUGH fan-out targets `_num_instances`. Instance assignment is done by 
`DistributePlanner`, which runs **after** translation.
   
   So it runs in `addLocalExchangeAfterDistribute()` — right after 
`splitFragments()` + `doDistribute()` — because that's the first point where 
both the BE-facing PlanNode tree and the instance assignment exist. Doing it 
pre-translation in Nereids would require re-deriving the fragment structure and 
instance counts that haven't been computed yet.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to