SNOW-3152139: Create UDF_init_once decorator in python client#4269
Merged
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
Collaborator
Author
|
I have read the CLA Document and I hereby sign the CLA |
sfc-gh-gshe
reviewed
Jun 30, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4269 +/- ##
=======================================
Coverage 95.52% 95.53%
=======================================
Files 171 171
Lines 44360 44368 +8
Branches 7577 7579 +2
=======================================
+ Hits 42377 42385 +8
Misses 1221 1221
Partials 762 762 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
4683d4d to
bf74a74
Compare
sfc-gh-bkogan
approved these changes
Jul 1, 2026
sfc-gh-aling
approved these changes
Jul 1, 2026
sfc-gh-aling
reviewed
Jul 1, 2026
The client-side udf_init_once decorator only tags the function and does not execute it, so setup() does not run and _multiplier stays 1. Assert the UDF returns inputs unchanged ([1, 2, 3]) to verify the decorated handler file registers and runs without error via register_from_file. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…e stale â�� only the Linux hashes got updated when test_udf_init_once_file.py was added
43cb13f to
8f2931b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SNOW-3152139: Create UDF_init_once decorator in python client
What
Adds the udf_init_once decorator to snowflake.snowpark.functions, providing a client-side definition that matches the server-side _snowflake.udf_init_once API.
Why
The @udf_init_once decorator allows users to mark zero-argument functions for one-time execution during pre-fork initialization on Snowflake workers. Initialized state (e.g., loaded models, computed lookup tables) is shared across all workers via Copy-On-Write. This avoids redundant initialization in each worker process.
Fill out the following pre-review checklist:
Please describe how your code solves the related issue.
Added the
udf_init_oncedecorator insnowflake.snowpark.functionsfor marking functions to be executed once during pre-fork initialization on Snowflake workers, matching the server-side_snowflake.udf_init_onceAPI.