Skip to content

Commit

Permalink
Java conditional joins should not require matching column counts (rap…
Browse files Browse the repository at this point in the history
…idsai#8955)

The Java conditional join APIs had a copy-n-paste error from the equality join code where it mandated the left and right table column counts matched.  Conditional joins use an AST expression for the join condition which does not require a 1-to-1 mapping between left and right table columns, so this check has been removed from the conditional join APIs.

Authors:
  - Jason Lowe (https://github.com/jlowe)

Approvers:
  - Robert (Bobby) Evans (https://github.com/revans2)

URL: rapidsai#8955
  • Loading branch information
jlowe authored and shwina committed Aug 9, 2021
1 parent 0219d60 commit 20bb17f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 25 deletions.
20 changes: 0 additions & 20 deletions java/src/main/java/ai/rapids/cudf/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -2004,10 +2004,6 @@ public GatherMap[] leftJoinGatherMaps(Table rightKeys, boolean compareNullsEqual
*/
public GatherMap[] leftJoinGatherMaps(Table rightTable, CompiledExpression condition,
boolean compareNullsEqual) {
if (getNumberOfColumns() != rightTable.getNumberOfColumns()) {
throw new IllegalArgumentException("column count mismatch, this: " + getNumberOfColumns() +
"rightKeys: " + rightTable.getNumberOfColumns());
}
long[] gatherMapData =
conditionalLeftJoinGatherMaps(getNativeView(), rightTable.getNativeView(),
condition.getNativeHandle(), compareNullsEqual);
Expand Down Expand Up @@ -2049,10 +2045,6 @@ public GatherMap[] innerJoinGatherMaps(Table rightKeys, boolean compareNullsEqua
*/
public GatherMap[] innerJoinGatherMaps(Table rightTable, CompiledExpression condition,
boolean compareNullsEqual) {
if (getNumberOfColumns() != rightTable.getNumberOfColumns()) {
throw new IllegalArgumentException("column count mismatch, this: " + getNumberOfColumns() +
"rightKeys: " + rightTable.getNumberOfColumns());
}
long[] gatherMapData =
conditionalInnerJoinGatherMaps(getNativeView(), rightTable.getNativeView(),
condition.getNativeHandle(), compareNullsEqual);
Expand Down Expand Up @@ -2094,10 +2086,6 @@ public GatherMap[] fullJoinGatherMaps(Table rightKeys, boolean compareNullsEqual
*/
public GatherMap[] fullJoinGatherMaps(Table rightTable, CompiledExpression condition,
boolean compareNullsEqual) {
if (getNumberOfColumns() != rightTable.getNumberOfColumns()) {
throw new IllegalArgumentException("column count mismatch, this: " + getNumberOfColumns() +
"rightKeys: " + rightTable.getNumberOfColumns());
}
long[] gatherMapData =
conditionalFullJoinGatherMaps(getNativeView(), rightTable.getNativeView(),
condition.getNativeHandle(), compareNullsEqual);
Expand Down Expand Up @@ -2146,10 +2134,6 @@ public GatherMap leftSemiJoinGatherMap(Table rightKeys, boolean compareNullsEqua
*/
public GatherMap leftSemiJoinGatherMap(Table rightTable, CompiledExpression condition,
boolean compareNullsEqual) {
if (getNumberOfColumns() != rightTable.getNumberOfColumns()) {
throw new IllegalArgumentException("column count mismatch, this: " + getNumberOfColumns() +
"rightKeys: " + rightTable.getNumberOfColumns());
}
long[] gatherMapData =
conditionalLeftSemiJoinGatherMap(getNativeView(), rightTable.getNativeView(),
condition.getNativeHandle(), compareNullsEqual);
Expand Down Expand Up @@ -2191,10 +2175,6 @@ public GatherMap leftAntiJoinGatherMap(Table rightKeys, boolean compareNullsEqua
*/
public GatherMap leftAntiJoinGatherMap(Table rightTable, CompiledExpression condition,
boolean compareNullsEqual) {
if (getNumberOfColumns() != rightTable.getNumberOfColumns()) {
throw new IllegalArgumentException("column count mismatch, this: " + getNumberOfColumns() +
"rightKeys: " + rightTable.getNumberOfColumns());
}
long[] gatherMapData =
conditionalLeftAntiJoinGatherMap(getNativeView(), rightTable.getNativeView(),
condition.getNativeHandle(), compareNullsEqual);
Expand Down
20 changes: 15 additions & 5 deletions java/src/test/java/ai/rapids/cudf/TableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,9 @@ void testConditionalLeftJoinGatherMaps() {
new ColumnReference(0, TableReference.LEFT),
new ColumnReference(0, TableReference.RIGHT));
try (Table left = new Table.TestBuilder().column(2, 3, 9, 0, 1, 7, 4, 6, 5, 8).build();
Table right = new Table.TestBuilder().column(6, 5, 9, 8, 10, 32).build();
Table right = new Table.TestBuilder()
.column(6, 5, 9, 8, 10, 32)
.column(0, 1, 2, 3, 4, 5).build();
Table expected = new Table.TestBuilder()
.column( 0, 1, 2, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9, 9)
.column(inv, inv, 0, 1, 3, inv, inv, 0, 1, inv, 1, inv, 0, 1)
Expand Down Expand Up @@ -1589,7 +1591,9 @@ void testConditionalInnerJoinGatherMaps() {
new ColumnReference(0, TableReference.LEFT),
new ColumnReference(0, TableReference.RIGHT));
try (Table left = new Table.TestBuilder().column(2, 3, 9, 0, 1, 7, 4, 6, 5, 8).build();
Table right = new Table.TestBuilder().column(6, 5, 9, 8, 10, 32).build();
Table right = new Table.TestBuilder()
.column(6, 5, 9, 8, 10, 32)
.column(0, 1, 2, 3, 4, 5).build();
Table expected = new Table.TestBuilder()
.column(2, 2, 2, 5, 5, 7, 9, 9)
.column(0, 1, 3, 0, 1, 1, 0, 1)
Expand Down Expand Up @@ -1684,7 +1688,9 @@ void testConditionalFullJoinGatherMaps() {
new ColumnReference(0, TableReference.LEFT),
new ColumnReference(0, TableReference.RIGHT));
try (Table left = new Table.TestBuilder().column(2, 3, 9, 0, 1, 7, 4, 6, 5, 8).build();
Table right = new Table.TestBuilder().column(6, 5, 9, 8, 10, 32).build();
Table right = new Table.TestBuilder()
.column(6, 5, 9, 8, 10, 32)
.column(0, 1, 2, 3, 4, 5).build();
Table expected = new Table.TestBuilder()
.column(inv, inv, inv, 0, 1, 2, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9, 9)
.column( 2, 4, 5, inv, inv, 0, 1, 3, inv, inv, 0, 1, inv, 1, inv, 0, 1)
Expand Down Expand Up @@ -1763,7 +1769,9 @@ void testConditionalLeftSemiJoinGatherMap() {
new ColumnReference(0, TableReference.LEFT),
new ColumnReference(0, TableReference.RIGHT));
try (Table left = new Table.TestBuilder().column(2, 3, 9, 0, 1, 7, 4, 6, 5, 8).build();
Table right = new Table.TestBuilder().column(6, 5, 9, 8, 10, 32).build();
Table right = new Table.TestBuilder()
.column(6, 5, 9, 8, 10, 32)
.column(0, 1, 2, 3, 4, 5).build();
Table expected = new Table.TestBuilder()
.column(2, 5, 7, 9) // left
.build();
Expand Down Expand Up @@ -1827,7 +1835,9 @@ void testConditionalLeftAntiJoinGatherMap() {
new ColumnReference(0, TableReference.LEFT),
new ColumnReference(0, TableReference.RIGHT));
try (Table left = new Table.TestBuilder().column(2, 3, 9, 0, 1, 7, 4, 6, 5, 8).build();
Table right = new Table.TestBuilder().column(6, 5, 9, 8, 10, 32).build();
Table right = new Table.TestBuilder()
.column(6, 5, 9, 8, 10, 32)
.column(0, 1, 2, 3, 4, 5).build();
Table expected = new Table.TestBuilder()
.column(0, 1, 3, 4, 6, 8) // left
.build();
Expand Down

0 comments on commit 20bb17f

Please sign in to comment.