File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -794,7 +794,9 @@ def get_schema(
794794
795795 # See if it's a Table subclass with annotations
796796 if inspect .isclass (origin ) and origin is Table :
797+
797798 function_type = 'tvf'
799+
798800 if utils .is_dataframe (args [0 ]):
799801 if not overrides :
800802 raise TypeError (
@@ -828,6 +830,10 @@ def get_schema(
828830 'or tuple of vectors' ,
829831 )
830832
833+ # Short circuit check for common valid types
834+ elif utils .is_vector (spec ) or spec in [str , float , int , bytes ]:
835+ pass
836+
831837 # Try to catch some common mistakes
832838 elif origin in [tuple , dict ] or tuple in args_origins or \
833839 (
@@ -841,9 +847,14 @@ def get_schema(
841847 )
842848 ):
843849 raise TypeError (
844- 'return type for table-valued functions must be annotated with a Table,' ,
850+ 'invalid return type for a UDF; '
851+ f'expecting a scalar or vector, but got { spec } ' ,
845852 )
846853
854+ # Short circuit check for common valid types
855+ elif utils .is_vector (spec ) or spec in [str , float , int , bytes ]:
856+ pass
857+
847858 # Error out for incorrect parameter types
848859 elif origin in [tuple , dict ] or tuple in args_origins or \
849860 (
You can’t perform that action at this time.
0 commit comments