snowflakedb / snowflakedb/snowpark-python
SNOW-2913796: [Local Testing] Add support for nullifzero function
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 341
- Forks
- 155
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 27
Description
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), returnNULL - 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:
-
mock_nullifzerofunction insrc/snowflake/snowpark/mock/_functions.py -
test_nullifzerotest case intests/mock/test_functions.py
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.