Check that all output symbols are provided by join inputs
@@ -19,12 +19,14 @@ import com.facebook.presto.sql.tree.Join;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
import javax.annotation.concurrent.Immutable;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
+import java.util.Set;
import static com.facebook.presto.sql.planner.plan.JoinNode.Type.INNER;
import static com.google.common.base.Preconditions.checkArgument;
@@ -70,6 +72,12 @@ public class JoinNode
requireNonNull(leftHashSymbol, "leftHashSymbol is null");
requireNonNull(rightHashSymbol, "rightHashSymbol is null");
+ Set<Symbol> inputSymbols = ImmutableSet.<Symbol>builder()
+ .addAll(left.getOutputSymbols())
+ .addAll(right.getOutputSymbols())
+ .build();
+ checkArgument(inputSymbols.containsAll(outputSymbols), "Left and right join inputs do not contain all output symbols");
+
this.type = type;
this.left = left;
this.right = right;
