kongfanshen-0801 opened a new pull request, #1799:
URL: https://github.com/apache/cloudberry/pull/1799

   ## What
   
   Backports two upstream PostgreSQL commits that add **Hash Right Semi Join**:
   
   - `aa86129e1` — Support "Right Semi Join" plan shapes
   - `5668a857d` — Fix right-semi-joins in HashJoin rescans
   
   This lets the planner build the hash table on the smaller (LHS) side of an
   `IN`/`EXISTS` semijoin instead of always hashing the inner relation.
   
   ## Cloudberry/GPDB-specific adaptations
   
   - **nodes.h**: `JOIN_RIGHT_SEMI` is appended at the **end** of the `JoinType`
     enum rather than in upstream's mid-list position. Inserting it mid-list
     shifts the integer values of the GPDB-only `JOIN_DEDUP_SEMI`/`_REVERSE` and
     `JOIN_UNIQUE_*` codes, which corrupts MPP motion planning and crashes 
during
     dispatch (SIGSEGV in `setupCdbProcessList`). Appending keeps every existing
     value stable.
   - **cdbpath.c** (`cdbpath_motion_for_join`, serial + parallel switches):
     handle `JOIN_RIGHT_SEMI` like `JOIN_RIGHT`/`JOIN_RIGHT_ANTI` — the inner
     (build) side must not be replicated, since a right-semi join emits
     build-side rows.
   - **joinrels.c**: add the `JOIN_RIGHT_SEMI` path alongside `JOIN_SEMI` while
     preserving the existing GPDB `JOIN_DEDUP_SEMI` handling.
   
   ## Testing
   
   - Functional: `Hash Right Semi Join` is chosen for small-build-side 
semijoins;
     results verified correct (dedup semantics, rescan correctness, MPP 
execution
     across segments).
   - Regression: the `join` test expected output is still being reconciled
     against CI's canonical environment — hence this PR is opened as a 
**draft**.
   
   ## Notes
   
   - Only affects the PostgreSQL planner (`optimizer=off`); GPORCA does not
     generate `JOIN_RIGHT_SEMI`.
   


-- 
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