You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In PR #886, we added cuDF dtype coercion to safe_merge() in Engine.py:
ifengine_concrete==Engine.CUDFandlen(left) >0:
merge_cols= []
ifonisnotNone:
merge_cols= [on] ifisinstance(on, str) elselist(on)
elifleft_onisnotNone:
left_cols= [left_on] ifisinstance(left_on, str) elselist(left_on)
right_cols= [right_on] ifisinstance(right_on, str) elselist(right_on)
merge_cols=list(zip(left_cols, right_cols))
forcol_specinmerge_cols:
ifisinstance(col_spec, tuple):
left_col, right_col=col_specelse:
left_col=right_col=col_specifleft_colinleft.columnsandright_colinright.columns:
left_dtype=left[left_col].dtyperight_dtype=right[right_col].dtype# Cast right column to match left column type if they differifleft_dtype \!=right_dtype:
try:
right[right_col] =right[right_col].astype(left_dtype)
except (ValueError, TypeError):
pass# Let the merge fail naturally if cast is impossible
This has several issues:
Mutates input DataFrame - right[right_col] = ... modifies the caller's DataFrame in place
cuDF-only - pandas/dask/dask_cudf don't get this fix even though they may have similar issues
Silent failure - the pass on exception hides potential problems
Why we backed it out
The mutation bug is serious - callers don't expect safe_merge to modify their input DataFrames. This can cause subtle bugs where a DataFrame is reused after a merge and has unexpectedly changed dtypes.
Context
The fix was added to handle empty cuDF DataFrames that have float64 columns due to type inference issues. When merging with a non-empty DataFrame, the dtype mismatch causes cuDF to fail.
Proposed Fix
Use .copy() before modifying: right = right.copy() before the dtype coercion
Consider if this should apply to all engines, not just cuDF
Add logging/warning instead of silent pass
Add tests to verify the fix works and doesn't mutate inputs
Activity
test: regression tests for #892, #881, #876 (already fixed on master)
test: add cuDF regression tests for #892, #881, #876
test: regression tests for #892, #881, #876 (already fixed on master)
test: add cuDF regression tests for #892, #881, #876
test: regression tests for graphistry#892, graphistry#881, graphistry…