|
218 | 218 | check_create_map_parameter, |
219 | 219 | deprecated, |
220 | 220 | private_preview, |
| 221 | + warning, |
221 | 222 | ) |
222 | 223 | from snowflake.snowpark._functions.scalar_functions import * # noqa: F403,F401 |
223 | 224 | from snowflake.snowpark.column import ( |
|
228 | 229 | _to_col_if_str, |
229 | 230 | _to_col_if_str_or_int, |
230 | 231 | ) |
231 | | -from snowflake.snowpark.stored_procedure import ( |
232 | | - StoredProcedure, |
233 | | - StoredProcedureRegistration, |
234 | | -) |
| 232 | +from snowflake.snowpark.stored_procedure import StoredProcedure |
235 | 233 | from snowflake.snowpark.types import ( |
236 | 234 | ArrayType, |
237 | 235 | DataType, |
|
242 | 240 | TimestampTimeZone, |
243 | 241 | TimestampType, |
244 | 242 | ) |
245 | | -from snowflake.snowpark.udaf import UDAFRegistration, UserDefinedAggregateFunction |
246 | | -from snowflake.snowpark.udf import UDFRegistration, UserDefinedFunction |
247 | | -from snowflake.snowpark.udtf import UDTFRegistration, UserDefinedTableFunction |
| 243 | +from snowflake.snowpark.udaf import UserDefinedAggregateFunction |
| 244 | +from snowflake.snowpark.udf import UserDefinedFunction |
| 245 | +from snowflake.snowpark.udtf import UserDefinedTableFunction |
248 | 246 |
|
249 | 247 | # Python 3.8 needs to use typing.Iterable because collections.abc.Iterable is not subscriptable |
250 | 248 | # Python 3.9 can use both |
@@ -9295,7 +9293,7 @@ def udf( |
9295 | 9293 | resource_constraint: Optional[Dict[str, str]] = None, |
9296 | 9294 | _emit_ast: bool = True, |
9297 | 9295 | **kwargs, |
9298 | | -) -> Union[UserDefinedFunction, functools.partial]: |
| 9296 | +) -> Union[UserDefinedFunction, functools.partial, Callable]: |
9299 | 9297 | """Registers a Python function as a Snowflake Python UDF and returns the UDF. |
9300 | 9298 |
|
9301 | 9299 | It can be used as either a function call or a decorator. In most cases you work with a single session. |
@@ -9462,7 +9460,13 @@ def udf( |
9462 | 9460 | ) |
9463 | 9461 |
|
9464 | 9462 | if session is None: |
9465 | | - udf_registration_method = UDFRegistration(session=session).register |
| 9463 | + warning( |
| 9464 | + name=f"udf_no_active_session_{func.__name__ if func else 'unknown'}", |
| 9465 | + text="WARN: UDF registration requires an active session. " |
| 9466 | + "This function was not registered.", |
| 9467 | + warning_times=1, |
| 9468 | + ) |
| 9469 | + return func |
9466 | 9470 | else: |
9467 | 9471 | udf_registration_method = session.udf.register |
9468 | 9472 |
|
@@ -9548,7 +9552,7 @@ def udtf( |
9548 | 9552 | resource_constraint: Optional[Dict[str, str]] = None, |
9549 | 9553 | _emit_ast: bool = True, |
9550 | 9554 | **kwargs, |
9551 | | -) -> Union[UserDefinedTableFunction, functools.partial]: |
| 9555 | +) -> Union[UserDefinedTableFunction, functools.partial, Callable]: |
9552 | 9556 | """Registers a Python class as a Snowflake Python UDTF and returns the UDTF. |
9553 | 9557 |
|
9554 | 9558 | It can be used as either a function call or a decorator. In most cases you work with a single session. |
@@ -9712,7 +9716,13 @@ def udtf( |
9712 | 9716 | session |
9713 | 9717 | ) |
9714 | 9718 | if session is None: |
9715 | | - udtf_registration_method = UDTFRegistration(session=session).register |
| 9719 | + warning( |
| 9720 | + name=f"udtf_no_active_session_{handler.__name__ if handler else 'unknown'}", |
| 9721 | + text="WARN: UDTF registration requires an active session. " |
| 9722 | + "This function was not registered.", |
| 9723 | + warning_times=1, |
| 9724 | + ) |
| 9725 | + return handler |
9716 | 9726 | else: |
9717 | 9727 | udtf_registration_method = session.udtf.register |
9718 | 9728 |
|
@@ -9964,7 +9974,13 @@ def udaf( |
9964 | 9974 | session |
9965 | 9975 | ) |
9966 | 9976 | if session is None: |
9967 | | - udaf_registration_method = UDAFRegistration(session=session).register |
| 9977 | + warning( |
| 9978 | + name=f"udaf_no_active_session_{handler.__name__ if handler else 'unknown'}", |
| 9979 | + text="WARN: UDAF registration requires an active session. " |
| 9980 | + "This function was not registered.", |
| 9981 | + warning_times=1, |
| 9982 | + ) |
| 9983 | + return handler |
9968 | 9984 | else: |
9969 | 9985 | udaf_registration_method = session.udaf.register |
9970 | 9986 |
|
@@ -10660,9 +10676,13 @@ def sproc( |
10660 | 10676 | session |
10661 | 10677 | ) |
10662 | 10678 | if session is None: |
10663 | | - sproc_registration_method = StoredProcedureRegistration( |
10664 | | - session=session |
10665 | | - ).register |
| 10679 | + warning( |
| 10680 | + name=f"sproc_no_active_session_{func.__name__ if func else 'unknown'}", |
| 10681 | + text="WARN: SPROC registration requires an active session. " |
| 10682 | + "This function was not registered.", |
| 10683 | + warning_times=1, |
| 10684 | + ) |
| 10685 | + return func |
10666 | 10686 | else: |
10667 | 10687 | sproc_registration_method = session.sproc.register |
10668 | 10688 |
|
|
0 commit comments