diff --git a/CHANGELOG.md b/CHANGELOG.md index 17eaff2c5ff..29548a437d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## 1.12.0 (TBD) ### Bug Fixes + +- Fixed a bug in `DataFrame.na.fill` that caused Boolean values to erroneously override integer values. - Fixed sql simplifier for filter with window function columns in select. ## 1.11.1 (2023-12-07) diff --git a/src/snowflake/snowpark/dataframe_na_functions.py b/src/snowflake/snowpark/dataframe_na_functions.py index 387a2e722d5..aecc5070fba 100644 --- a/src/snowflake/snowpark/dataframe_na_functions.py +++ b/src/snowflake/snowpark/dataframe_na_functions.py @@ -48,6 +48,8 @@ def _is_value_type_matching_for_na_function( value is None or ( isinstance(value, int) + # bool is a subclass of int, but we don't want to consider it numeric + and not isinstance(value, bool) and isinstance(datatype, (IntegerType, LongType, FloatType, DoubleType)) ) or (isinstance(value, float) and isinstance(datatype, (FloatType, DoubleType))) @@ -285,6 +287,17 @@ def fill( |3.14 |15 | -------------- + >>> df2 = session.create_dataframe([[1.0, True], [2.0, False], [3.0, False], [None, None]]).to_df("a", "b") + >>> df2.na.fill(True).show() + ---------------- + |"A" |"B" | + ---------------- + |1.0 |True | + |2.0 |False | + |3.0 |False | + |NULL |True | + ---------------- + Note: If the type of a given value in ``value`` doesn't match the