What is the current behavior?
The nullifzero() function is not implemented in the Local Testing Framework. When we attempt to use this function with local_testing=True, they encounter the following error:
from snowflake.snowpark import Session
from snowflake.snowpark.functions import col, nullifzero
session = Session.builder.config("local_testing", True).create()
df = session.create_dataframe([[0], [1], [100]], schema=["value"])
result = df.select(nullifzero(col("value")))
result.show()
error:
NotImplementedError: [Local Testing] Function nullifzero is not implemented.
You can implement and make a patch by using the `snowflake.snowpark.mock.patch` decorator.
What is the desired behavior?
The nullifzero() function should work in Local Testing mode with the following behavior:
- When the input value is
0 (integer or float), return NULL
- When the input value is non-zero, return the original value
- Maintain the original data type while ensuring the result is nullable
This would match the behavior of Snowflake's NULLIFZERO SQL function.
If this is not an existing feature in snowflake-snowpark-python. How would this impact/improve non local testing mode?
This feature does not impact non-local testing mode. The nullifzero() function already works correctly when connected to Snowflake.
References, Other Background
#4036
I'm willing to implement this feature and submit a pull request. The implementation would include:
What is the current behavior?
The
nullifzero()function is not implemented in the Local Testing Framework. When we attempt to use this function withlocal_testing=True, they encounter the following error:error:
NotImplementedError: [Local Testing] Function nullifzero is not implemented. You can implement and make a patch by using the `snowflake.snowpark.mock.patch` decorator.What is the desired behavior?
The
nullifzero()function should work in Local Testing mode with the following behavior:0(integer or float), returnNULLThis would match the behavior of Snowflake's
NULLIFZEROSQL function.If this is not an existing feature in
snowflake-snowpark-python. How would this impact/improve non local testing mode?This feature does not impact non-local testing mode. The
nullifzero()function already works correctly when connected to Snowflake.References, Other Background
#4036
I'm willing to implement this feature and submit a pull request. The implementation would include:
mock_nullifzerofunction insrc/snowflake/snowpark/mock/_functions.pytest_nullifzerotest case intests/mock/test_functions.py