Skip to content

Commit

Permalink
Added support for cross joins - closes #56
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Apr 1, 2024
1 parent 0d00abc commit 9fa188d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Updated Polars to 0.38.3
- Added support for writing JSON to string
- Added support for writing Parquet to `StringIO`
- Added support for cross joins
- Added `data_page_size` option to `write_parquet` method
- Added `truncate_ragged_lines` option to `read_csv`, `read_csv_batched`, and `scan_csv` methods
- Added precompiled gem for Linux x86-64 MUSL
Expand Down
1 change: 1 addition & 0 deletions ext/polars/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ features = [
"binary_encoding",
"concat_str",
"cov",
"cross_join",
"cse",
"csv",
"cum_agg",
Expand Down
3 changes: 1 addition & 2 deletions ext/polars/src/conversion/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,8 +737,7 @@ impl TryConvert for Wrap<JoinType> {
"outer_coalesce" => JoinType::Outer { coalesce: true },
"semi" => JoinType::Semi,
"anti" => JoinType::Anti,
// #[cfg(feature = "cross_join")]
// "cross" => JoinType::Cross,
"cross" => JoinType::Cross,
v => {
return Err(RbValueError::new_err(format!(
"how must be one of {{'inner', 'left', 'outer', 'semi', 'anti', 'cross'}}, got {}",
Expand Down
2 changes: 1 addition & 1 deletion lib/polars/lazy_frame.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1839,7 +1839,7 @@ def join(
if how == "cross"
return _from_rbldf(
_ldf.join(
other._ldf, [], [], allow_parallel, force_parallel, how, suffix
other._ldf, [], [], allow_parallel, join_nulls, force_parallel, how, suffix
)
)
end
Expand Down
7 changes: 7 additions & 0 deletions test/data_frame_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,13 @@ def test_join_outer
assert_frame expected, df4
end

def test_join_cross
df1 = Polars::DataFrame.new({a: [1, 2]})
df2 = Polars::DataFrame.new({b: ["three", "four"]})
expected = Polars::DataFrame.new({a: [1, 1, 2, 2], b: ["three", "four", "three", "four"]})
assert_frame expected, df1.join(df2, how: "cross")
end

def test_with_column
end

Expand Down

0 comments on commit 9fa188d

Please sign in to comment.