snowflake.snowpark.stored_procedure.StoredProcedureRegistration.registerΒΆ
- StoredProcedureRegistration.register(func: Callable | Tuple[str, str], return_type: DataType | None = None, input_types: List[DataType] | None = None, name: str | Iterable[str] | None = None, is_permanent: bool = False, stage_location: str | None = None, imports: List[str | Tuple[str, str]] | None = None, packages: List[str | module] | None = None, replace: bool = False, parallel: int = 4, execute_as: Literal['caller', 'owner'] = 'owner', strict: bool = False, *, statement_params: Dict[str, str] | None = None) StoredProcedure [source]ΒΆ
Registers a Python function as a Snowflake Python stored procedure and returns the stored procedure. The usage, input arguments, and return value of this method are the same as they are for
sproc()
, butregister()
cannot be used as a decorator. See examples inStoredProcedureRegistration
.- Parameters:
func β A Python function used for creating the stored procedure. Note that the first parameter of your function should be a snowpark Session.
return_type β A
DataType
representing the return data type of the stored procedure. Optional if type hints are provided.input_types β A list of
DataType
representing the input data types of the stored procedure. Optional if type hints are provided.name β A string or list of strings that specify the name or fully-qualified object identifier (database name, schema name, and function name) for the stored procedure in Snowflake, which allows you to call this stored procedure in a SQL command or via
call()
. If it is not provided, a name will be automatically generated for the stored procedure. A name must be specified whenis_permanent
isTrue
.is_permanent β Whether to create a permanent stored procedure. The default is
False
. If it isTrue
, a validstage_location
must be provided.stage_location β The stage location where the Python file for the stored procedure and its dependencies should be uploaded. The stage location must be specified when
is_permanent
isTrue
, and it will be ignored whenis_permanent
isFalse
. It can be any stage other than temporary stages and external stages.imports β A list of imports that only apply to this stored procedure. You can use a string to represent a file path (similar to the
path
argument inadd_import()
) in this list, or a tuple of two strings to represent a file path and an import path (similar to theimport_path
argument inadd_import()
). These stored procedure-level imports will override the session-level imports added byadd_import()
.packages β A list of packages that only apply to this stored procedure. These stored procedure-level packages will override the session-level packages added by
add_packages()
andadd_requirements()
.replace β Whether to replace a stored procedure that already was registered. The default is
False
. If it isFalse
, attempting to register a stored procedure with a name that already exists results in aSnowparkSQLException
exception being thrown. If it isTrue
, an existing stored procedure with the same name is overwritten.parallel β The number of threads to use for uploading stored procedure files with the PUT command. The default value is 4 and supported values are from 1 to 99. Increasing the number of threads can improve performance when uploading large stored procedure files.
execute_as β What permissions should the procedure have while executing. This supports caller, or owner for now.
strict β Whether the created stored procedure is strict. A strict stored procedure will not invoke the stored procedure if any input is null. Instead, a null value will always be returned. Note that the stored procedure might still return null for non-null inputs.
statement_params β Dictionary of statement level parameters to be set while executing this action.
See also