From 20bb17fcf70fe6ddf8fe41a488b0581dbc6a5d6d Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Fri, 6 Aug 2021 08:40:48 -0500 Subject: [PATCH] Java conditional joins should not require matching column counts (#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: https://github.com/rapidsai/cudf/pull/8955 --- java/src/main/java/ai/rapids/cudf/Table.java | 20 ------------------- .../test/java/ai/rapids/cudf/TableTest.java | 20 ++++++++++++++----- 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/java/src/main/java/ai/rapids/cudf/Table.java b/java/src/main/java/ai/rapids/cudf/Table.java index 360bb5c7467..861c6485a5c 100644 --- a/java/src/main/java/ai/rapids/cudf/Table.java +++ b/java/src/main/java/ai/rapids/cudf/Table.java @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); diff --git a/java/src/test/java/ai/rapids/cudf/TableTest.java b/java/src/test/java/ai/rapids/cudf/TableTest.java index 1b2ed1ad0b8..6b347897f82 100644 --- a/java/src/test/java/ai/rapids/cudf/TableTest.java +++ b/java/src/test/java/ai/rapids/cudf/TableTest.java @@ -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) @@ -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) @@ -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) @@ -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(); @@ -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();