ERROR: illegal rescan of motion node: invalid plan (nodeMotion.c:1632) HINT: Likely caused by bad NL-join, try setting enable_nestloop to off
Setting the GUC "optimizer_trace_fallback" to on reveals the LATERAL JOIN.
set optimizer_trace_fallback=on; <SELECT QUERY WITH LATERAL JOIN> INFO: GPORCA failed to produce a plan, falling back to planner DETAIL: Feature not supported: LATERAL ERROR: illegal rescan of motion node: invalid plan (nodeMotion.c:1632) HINT: Likely caused by bad NL-join, try setting enable_nestloop to off
set join_collapse_limit = 1Otherwise query needs to be rewritten to avoid LATERAL JOIN.