Adam Augusta
03/16/2023, 8:18 PMtEnv.createTemporaryView(“contractswithevents”, “select contract_id, isin, leg1.events as leg1events, leg2.events as leg2events from contracts”));
Table leg1Events = tEnv.sqlQuery(“select contract_id, isin, ‘leg1’ as leg, e.event_id, e.quantity from contractswithevents CROSS JOIN UNNEST(leg1events) as e(event_id, quantity)”);
Table leg2Events = …
Table events = leg1Events.unionAll(leg2Events);
TablePipeline pipeline = events.groupBy($(“contract_id”), $(“quantity”).sum()).insertInto(“results”);
The optimized execution plan has 2 `Exchange(distribution=[hash[contract_id]])`s, one after the scan, and one between the union and the aggregate.
What gives? Is the planner getting baffled by the unnest?Martijn Visser
03/16/2023, 8:20 PMAdam Augusta
03/16/2023, 8:24 PMMartijn Visser
03/16/2023, 8:25 PMSergey Nuyanzin
03/17/2023, 6:36 AMorg.apache.calcite.plan.RuleEventLogger#ruleProductionSucceeded
is called after each successfully applied rule (Calcite's or Flink's rule).
Moreover it is possible to see this rule and the plan after this rule is applied. At least with Calcite 1.29.0 -1.30.0 the logging was significantly improved there.