Summary
Three telemetry decorators in snowflake/snowpark/_internal/telemetry.py are completely untyped, causing all DataFrame and RelationalGroupedDataFrame methods they wrap to return Unknown under strict type checkers (pyright, ty).
Root Cause
# telemetry.py — all three follow this pattern
def df_api_usage(func): # no type variables
def wrap(*args, **kwargs): # no type variables
...
return r
return wrap
df_api_usage is the outermost decorator on DataFrame methods — applied after @publicapi — so it erases the type signature that @publicapi carefully preserves via CallableT:
@df_api_usage # outer — strips all type information
@publicapi # inner — uses CallableT correctly, but now overridden
def select(self, *cols) -> "DataFrame":
...
The same problem affects df_to_relational_group_df_api_usage and relational_group_df_api_usage.
Fix
Apply the same CallableT pattern used to fix publicapi in #2999:
from typing import TypeVar, Callable
_FuncT = TypeVar("_FuncT", bound=Callable)
def df_api_usage(func: _FuncT) -> _FuncT:
@functools.wraps(func)
def wrap(*args, **kwargs):
...
return r
return wrap # type: ignore[return-value]
Apply the same fix to df_to_relational_group_df_api_usage and relational_group_df_api_usage.
Affected methods
Every public DataFrame method decorated with @df_api_usage — including select, filter, with_column, join, union, group_by, etc. — and every RelationalGroupedDataFrame aggregation method.
Related
Summary
Three telemetry decorators in
snowflake/snowpark/_internal/telemetry.pyare completely untyped, causing allDataFrameandRelationalGroupedDataFramemethods they wrap to returnUnknownunder strict type checkers (pyright, ty).Root Cause
df_api_usageis the outermost decorator onDataFramemethods — applied after@publicapi— so it erases the type signature that@publicapicarefully preserves viaCallableT:The same problem affects
df_to_relational_group_df_api_usageandrelational_group_df_api_usage.Fix
Apply the same
CallableTpattern used to fixpublicapiin #2999:Apply the same fix to
df_to_relational_group_df_api_usageandrelational_group_df_api_usage.Affected methods
Every public
DataFramemethod decorated with@df_api_usage— includingselect,filter,with_column,join,union,group_by, etc. — and everyRelationalGroupedDataFrameaggregation method.Related
@publicapi)@publicapi)