Skip to content

Commit 69c1deb

Browse files
committed
Short circuit common valid types
1 parent 5423ed7 commit 69c1deb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

singlestoredb/functions/signature.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff 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
(

0 commit comments

Comments
 (0)