Skip to content

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

@mkanetsuna

Description

@mkanetsuna

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

Metadata

Metadata

Labels

local testingLocal Testing issues/PRsstatus-pr_pending_mergeA PR is made and is under reviewstatus-triage_doneInitial triage done, will be further handled by the driver team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions