diff --git a/src/engine/QueryPlanner.cpp b/src/engine/QueryPlanner.cpp index 96947a9f9d..0df49f3fe7 100644 --- a/src/engine/QueryPlanner.cpp +++ b/src/engine/QueryPlanner.cpp @@ -1817,6 +1817,13 @@ std::vector QueryPlanner::createJoinCandidates( return candidates; } + // If both sides are spatial joins, return immediately to prevent a regular + // join on the variables, which would lead to the spatial join never having + // children. + if (checkSpatialJoin(a, b) == std::pair{true, true}) { + return candidates; + } + // if one of the inputs is the spatial join and the other input is compatible // with the SpatialJoin, add it as a child to the spatialJoin. As unbound // SpatialJoin operations are incompatible with normal join operations, we @@ -1828,13 +1835,6 @@ std::vector QueryPlanner::createJoinCandidates( return candidates; } - // If both sides are spatial joins, return immediately to prevent a regular - // join on the variables, which would lead to the spatial join never having - // children. - if (checkSpatialJoin(a, b) == std::pair{true, true}) { - return candidates; - } - if (a.type == SubtreePlan::MINUS) { AD_THROW( "MINUS can only appear after"