Source:
<code>private PhysicalOperation createSpatialJoin(JoinNode node, LocalExecutionPlanContext context) { Verify.verify(node.getFilter().isPresent()); Expression filterExpression = node.getFilter().get(); List<FunctionCall> spatialFunctions = extractSupportedSpatialFunctions(filterExpression); for (FunctionCall spatialFunction : spatialFunctions) { List<Expression> arguments = spatialFunction.getArguments(); Verify.verify(arguments.size() == 2); if (!(arguments.get(0) instanceof SymbolReference) || !(arguments.get(1) instanceof SymbolReference)) { continue; } String firstSymbol = ((SymbolReference) arguments.get(0)).getName(); String secondSymbol = ((SymbolReference) arguments.get(1)).getName(); PlanNode probeNode = node.getLeft(); Set<String> probeSymbols = getSymbolNames(probeNode.getOutputSymbols()); PlanNode buildNode = node.getRight(); Set<String> buildSymbols = getSymbolNames(buildNode.getOutputSymbols()); if (probeSymbols.contains(firstSymbol) && buildSymbols.contains(secondSymbol)) { <START> return createSpatialLookupJoin(node, <END> probeNode, getOutputSymbolByName(probeNode, firstSymbol), buildNode, getOutputSymbolByName(buildNode, secondSymbol), spatialTest(spatialFunction, true), removeExpressionFromFilter(filterExpression, spatialFunction), context); } else if (probeSymbols.contains(secondSymbol) && buildSymbols.contains(firstSymbol)) { return createSpatialLookupJoin(node, probeNode, getOutputSymbolByName(probeNode, secondSymbol), buildNode, getOutputSymbolByName(buildNode, firstSymbol), spatialTest(spatialFunction, false), removeExpressionFromFilter(filterExpression, spatialFunction), context); } else { continue; } } throw new VerifyException("No valid spatial relationship found for spatial join"); }</code><technical_language>return early, if more spatial functions in this join</technical_language>

Target:
private PhysicalOperation createSpatialJoin(JoinNode node, LocalExecutionPlanContext context) { verify(node.getFilter().isPresent() && node.getCriteria().isEmpty()); Expression filterExpression = node.getFilter().get(); List<FunctionCall> spatialFunctions = extractSupportedSpatialFunctions(filterExpression); for (FunctionCall spatialFunction : spatialFunctions) { List<Expression> arguments = spatialFunction.getArguments(); verify(arguments.size() == 2); if (!(arguments.get(0) instanceof SymbolReference) || !(arguments.get(1) instanceof SymbolReference)) { continue; } SymbolReference firstSymbol = (SymbolReference) arguments.get(0); SymbolReference secondSymbol = (SymbolReference) arguments.get(1); PlanNode probeNode = node.getLeft(); Set<SymbolReference> probeSymbols = getSymbolReferences(probeNode.getOutputSymbols()); PlanNode buildNode = node.getRight(); Set<SymbolReference> buildSymbols = getSymbolReferences(buildNode.getOutputSymbols()); if (probeSymbols.contains(firstSymbol) && buildSymbols.contains(secondSymbol)) { return createSpatialLookupJoin( node, probeNode, Symbol.from(firstSymbol), buildNode, Symbol.from(secondSymbol), spatialTest(spatialFunction, true), removeExpressionFromFilter(filterExpression, spatialFunction), context); } else if (probeSymbols.contains(secondSymbol) && buildSymbols.contains(firstSymbol)) { return createSpatialLookupJoin( node, probeNode, Symbol.from(secondSymbol), buildNode, Symbol.from(firstSymbol), spatialTest(spatialFunction, false), removeExpressionFromFilter(filterExpression, spatialFunction), context); } } throw new VerifyException("No valid spatial relationship found for spatial join"); }