The transformation context
The operation to transform
The transformed operation with incompatible branches eliminated
// Given query: SELECT * { ?s ?p ?o . <ex://a> ?p ?o }
// With mappings: CONSTRUCT WHERE { <ex://a> <ex://a> ?o }
// CONSTRUCT WHERE { <ex://b> <ex://b> ?o }
//
// The first pattern creates a UNION binding ?s to <ex://a> or <ex://b>
// The second pattern requires subject <ex://a>, constraining ?p
// Since ?p from the <ex://b> mapping (value <ex://b>) doesn't match
// the ?p from the second pattern (which works with <ex://a>),
// the <ex://b> branch is eliminated.
// With 3 mappings where the third has subject <ex://b>:
// CONSTRUCT WHERE { <ex://a> <ex://a> ?o }
// CONSTRUCT WHERE { <ex://a> <ex://b> ?o }
// CONSTRUCT WHERE { <ex://b> <ex://c> ?o }
//
// The third mapping would bind ?s = <ex://b>, but the second pattern
// in the query has subject <ex://a>. Since these are incompatible,
// only the first two mappings (both with ?s = <ex://a>) survive.
Optimization transformation that detects and eliminates incompatible join branches.
After query rewriting, a JOIN may contain UNION branches where different alternatives bind variables to incompatible values. This transformation:
It reads each join operand's top-level
EXTENDchain and its recursion halts at aPROJECT, so a bind still inside a sub-SELECT is invisible to it. That is why the default pipeline runs it afterremoveProjectionsandpullUpExtends, and why it is inert anywhere earlier.