Skip to content

Commit

Permalink
Small improvement to exception message when a natural join finds mult…
Browse files Browse the repository at this point in the history
…iple right hand matches.
  • Loading branch information
jcferretti committed Feb 2, 2022
1 parent 2e357f0 commit 5c00abf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2025,7 +2025,7 @@ public RowSet getLeftIndex(long slot) {
private long getResultRightIndex(long hashSlot) {
final long rightIndex = getRightIndex(hashSlot);
if (rightIndex == DUPLICATE_RIGHT_VALUE) {
throw new IllegalStateException("Duplicate right key for " + keyString(hashSlot));
throw new IllegalStateException("Natural Join found duplicate right key for " + keyString(hashSlot));
}
return rightIndex;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ public void accept(long updatedSlot, long originalRightValue, byte flag) {
final long rightIndex = jsm.getRightIndex(updatedSlot);

if (rightIndex == StaticNaturalJoinStateManager.DUPLICATE_RIGHT_VALUE) {
throw new IllegalStateException("Duplicate right key for " + jsm.keyString(updatedSlot));
throw new IllegalStateException("Natural Join found duplicate right key for " + jsm.keyString(updatedSlot));
}

final boolean unchangedRedirection = rightIndex == originalRightValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,7 @@ private long getRightSide(final LongArraySource leftHashSlots, final long positi
final long stateValue = getStateValue(leftHashSlots, position);
if (stateValue == DUPLICATE_RIGHT_VALUE) {
final long hashSlot = leftHashSlots.getLong(position);
throw new IllegalStateException("Duplicate right key for " + keyString(hashSlot));
throw new IllegalStateException("Natural Join found duplicate right key for " + keyString(hashSlot));
}
return stateValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,8 @@ public void testNaturalJoinDuplicateRights() {
}
}

private final static String dupMsg = "Natural Join found duplicate right key for ";

public void testNaturalJoinDuplicateRightsRefreshingRight() {
// initial case
final Table left = testTable(c("Symbol", "A", "B"), c("LeftSentinel", 1, 2));
Expand All @@ -522,7 +524,7 @@ public void testNaturalJoinDuplicateRightsRefreshingRight() {
TableTools.showWithRowSet(cj);
fail("Expected exception.");
} catch (IllegalStateException rte) {
assertEquals("Duplicate right key for A", rte.getMessage());
assertEquals(dupMsg + "A", rte.getMessage());
}

// bad right key added
Expand All @@ -543,7 +545,7 @@ public void testNaturalJoinDuplicateRightsRefreshingRight() {
}

assertNotNull(listener.originalException());
assertEquals("Duplicate right key for A", listener.originalException().getMessage());
assertEquals(dupMsg + "A", listener.originalException().getMessage());
}

public void testNaturalJoinDuplicateRightsRefreshingBoth() {
Expand All @@ -556,7 +558,7 @@ public void testNaturalJoinDuplicateRightsRefreshingBoth() {
TableTools.showWithRowSet(cj);
fail("Expected exception.");
} catch (IllegalStateException rte) {
assertEquals("Duplicate right key for A", rte.getMessage());
assertEquals(dupMsg + "A", rte.getMessage());
}

// bad right key added
Expand All @@ -577,7 +579,7 @@ public void testNaturalJoinDuplicateRightsRefreshingBoth() {
}

assertNotNull(listener.originalException());
assertEquals("Duplicate right key for A", listener.originalException().getMessage());
assertEquals(dupMsg + "A", listener.originalException().getMessage());
}


Expand Down

0 comments on commit 5c00abf

Please sign in to comment.