Skip to content

Commit

Permalink
fix: mongo left outer join runs same logic than left join (#2225)
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-pinchelimouroux authored Sep 4, 2024
1 parent 328ae95 commit 26c4117
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
4 changes: 4 additions & 0 deletions server/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Changed

- Mongo: The `join` step now has the same behavior for the `left` and `left outer` join methods

## [0.26.17] - 2024-08-20

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ def translate_join(step: JoinStep) -> list[MongoStep]:
}
}
)

if step.type == "inner":
mongo_pipeline.append({"$unwind": "$_vqbJoinKey"})
elif step.type == "left":
elif step.type == "left" or step.type == "left outer":
mongo_pipeline.append(
{"$unwind": {"path": "$_vqbJoinKey", "preserveNullAndEmptyArrays": True}}
)
Expand Down
33 changes: 24 additions & 9 deletions server/tests/backends/fixtures/join/left_outer.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@
},
"data": [
{
"NAME": "foo",
"NAME": "full data",
"AGE": 42,
"SCORE": 100
},
{
"NAME": "fla",
"AGE": 42,
"SCORE": 100
"NAME": "ok - with null value",
"AGE": 1,
"SCORE": 1
}
]
},
Expand All @@ -85,8 +85,12 @@
},
"data": [
{
"NAME": "foo",
"NAME": "full data",
"X": 12
},
{
"NAME": "ko - must be missing",
"X": 360
}
]
}
Expand All @@ -105,16 +109,27 @@
{
"name": "SCORE",
"type": "integer"
},
{
"name": "X",
"type": "string"
}
],
"pandas_version": "0.20.0"
},
"data": [
{
"NAME": "fla",
"AGE": 42.0,
"SCORE": 100.0
"NAME": "full data",
"AGE": 42,
"SCORE": 100,
"X": 12
},
{
"NAME": "ok - with null value",
"AGE": 1,
"SCORE": 1,
"X": null
}
]
}
}
}

0 comments on commit 26c4117

Please sign in to comment.