Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions datafusion/src/physical_plan/hash_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ fn build_join_indexes(
for (row, hash_value) in hash_values.iter().enumerate() {
match left.0.get(*hash_value, |(hash, _)| *hash_value == *hash) {
Some((_, indices)) => {
let mut no_match = true;
for &i in indices {
if equal_rows(
i as usize,
Expand All @@ -745,9 +746,14 @@ fn build_join_indexes(
&keys_values,
)? {
left_indices.append_value(i)?;
} else {
left_indices.append_null()?;
right_indices.append_value(row as u32)?;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fix, instead of adding the (left=null, right) to every non-match, it does it only once at the end if there wasn't a single match.

no_match = false;
}
}
// If no rows matched left, still must keep the right
// with all nulls for left
if no_match {
left_indices.append_null()?;
right_indices.append_value(row as u32)?;
}
}
Expand All @@ -768,7 +774,7 @@ macro_rules! equal_rows_elem {
let left_array = $l.as_any().downcast_ref::<$array_type>().unwrap();
let right_array = $r.as_any().downcast_ref::<$array_type>().unwrap();

match (left_array.is_null($left), left_array.is_null($right)) {
match (left_array.is_null($left), right_array.is_null($right)) {
(false, false) => left_array.value($left) == right_array.value($right),
_ => false,
}
Expand Down Expand Up @@ -1372,8 +1378,6 @@ mod tests {
}

#[tokio::test]
// Disable until https://github.com/apache/arrow-datafusion/issues/843 fixed
#[cfg(not(feature = "force_hash_collisions"))]
async fn join_full_multi_batch() {
let left = build_table(
("a1", &vec![1, 2, 3]),
Expand Down Expand Up @@ -1639,8 +1643,6 @@ mod tests {
}

#[tokio::test]
// Disable until https://github.com/apache/arrow-datafusion/issues/843 fixed
#[cfg(not(feature = "force_hash_collisions"))]
async fn join_right_one() -> Result<()> {
let left = build_table(
("a1", &vec![1, 2, 3]),
Expand Down Expand Up @@ -1677,8 +1679,6 @@ mod tests {
}

#[tokio::test]
// Disable until https://github.com/apache/arrow-datafusion/issues/843 fixed
#[cfg(not(feature = "force_hash_collisions"))]
async fn partitioned_join_right_one() -> Result<()> {
let left = build_table(
("a1", &vec![1, 2, 3]),
Expand Down Expand Up @@ -1716,8 +1716,6 @@ mod tests {
}

#[tokio::test]
// Disable until https://github.com/apache/arrow-datafusion/issues/843 fixed
#[cfg(not(feature = "force_hash_collisions"))]
async fn join_full_one() -> Result<()> {
let left = build_table(
("a1", &vec![1, 2, 3]),
Expand Down
6 changes: 0 additions & 6 deletions datafusion/tests/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1797,8 +1797,6 @@ async fn equijoin_left_and_condition_from_right() -> Result<()> {
}

#[tokio::test]
// Disable until https://github.com/apache/arrow-datafusion/issues/843 fixed
#[cfg(not(feature = "force_hash_collisions"))]
async fn equijoin_right_and_condition_from_left() -> Result<()> {
let mut ctx = create_join_context("t1_id", "t2_id")?;
let sql =
Expand Down Expand Up @@ -1852,8 +1850,6 @@ async fn left_join() -> Result<()> {
}

#[tokio::test]
// Disable until https://github.com/apache/arrow-datafusion/issues/843 fixed
#[cfg(not(feature = "force_hash_collisions"))]
async fn right_join() -> Result<()> {
let mut ctx = create_join_context("t1_id", "t2_id")?;
let equivalent_sql = [
Expand All @@ -1874,8 +1870,6 @@ async fn right_join() -> Result<()> {
}

#[tokio::test]
// Disable until https://github.com/apache/arrow-datafusion/issues/843 fixed
#[cfg(not(feature = "force_hash_collisions"))]
async fn full_join() -> Result<()> {
let mut ctx = create_join_context("t1_id", "t2_id")?;
let equivalent_sql = [
Expand Down