Skip to content

Commit

Permalink
Issue bigdawg-istc#15 - flip left and right join type when child node…
Browse files Browse the repository at this point in the history
…s are likewise flipped
  • Loading branch information
mmucklo committed May 11, 2020
1 parent 66ed019 commit 6351739
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ public SQLIslandJoin (Map<String, String> parameters, List<String> output, SQLIs
super(parameters, output, lhs, rhs, supplement);

// mending non-canoncial ordering
boolean flipJoinType = false;
if (children.get(0) instanceof SQLIslandScan && !(children.get(1) instanceof SQLIslandScan)) {
SQLIslandOperator child0 = (SQLIslandOperator) children.get(1);
SQLIslandOperator child1 = (SQLIslandOperator) children.get(0);
children.clear();
children.add(child0);
children.add(child1);
flipJoinType = true;
}

this.isBlocking = false;
Expand Down Expand Up @@ -104,6 +106,14 @@ public SQLIslandJoin (Map<String, String> parameters, List<String> output, SQLIs
if (parameters.containsKey("Join-Type")) {
try {
joinType = JoinType.valueOf(parameters.get("Join-Type"));
// Have to potentially flip the join type as well.
if (flipJoinType) {
if (joinType == JoinType.Left) {
joinType = JoinType.Right;
} else if (joinType == JoinType.Right) {
joinType = JoinType.Left;
}
}
} catch (IllegalArgumentException e) {
// unknown join type
Logger.getLogger(this.getClass().getName()).warn("Unknown Join-Type returned: '" + parameters.get("Join-Type") + "'");
Expand Down Expand Up @@ -168,7 +178,7 @@ public SQLIslandJoin (SQLIslandOperator o, boolean addChild) throws IslandExcept

public SQLIslandJoin(Operator child0, Operator child1, JoinType jt, String joinPred, boolean isFilter) throws JSQLParserException {
this.isCTERoot = false; // TODO VERIFY
this.isBlocking = false;
this.isBlocking = false;
this.isPruned = false;
this.isCopy = true;
this.setAliases(new ArrayList<>());
Expand Down Expand Up @@ -209,7 +219,7 @@ public SQLIslandJoin(Operator child0, Operator child1, JoinType jt, String joinP

public SQLIslandJoin() {
super();

this.isCTERoot = false; // TODO VERIFY
this.isBlocking = false;
this.isPruned = false;
Expand All @@ -222,7 +232,7 @@ public SQLIslandJoin() {

@Override
public Join construct(Operator child0, Operator child1, JoinType jt, String joinPred, boolean isFilter) throws Exception {

this.isCopy = true;

if (jt != null) this.joinType = jt;
Expand Down

0 comments on commit 6351739

Please sign in to comment.