snowflakedb / snowflakedb/snowpark-python

SNOW-2913796: [Local Testing] Add support for nullifzero function

Open
#4,035 2 comments 0 reactions 2 assignees View on GitHub

Nobody has claimed this yet.

local testing status-pr_pending_merge status-triage_done
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), 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:

  • mock_nullifzero function in src/snowflake/snowpark/mock/_functions.py
  • test_nullifzero test case in tests/mock/test_functions.py

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.