Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-828211 Support registering vectorized UDTF #940

Merged
merged 10 commits into from
Jul 20, 2023
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- Added support for Geometry datatypes.
- Added support for `params` in `session.sql()` in stored procedures.
- Added support for UDAF. This feature is currently in private preview.
- Added support for vectorized UDTF. This feature is currently in public preview.
- Added support for Timestamp variants, i.e., `TIMESTAMP_NTZ`, `TIMESTAMP_LTZ`, `TIMESTAMP_TZ`

### Improvements
Expand Down
9 changes: 4 additions & 5 deletions src/snowflake/snowpark/_internal/type_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,10 @@ def retrieve_func_type_hints_from_source(
func_name: str,
class_name: Optional[str] = None,
_source: Optional[str] = None,
) -> Dict[str, str]:
) -> Optional[Dict[str, str]]:
"""
Retrieve type hints of a function from a source file, or a source string (test only).
Returna None if the function is not found.
"""

def parse_arg_annotation(annotation: ast.expr) -> str:
Expand Down Expand Up @@ -600,17 +601,15 @@ def visit_ClassDef(self, node):
class_visitor = ClassNodeVisitor()
class_visitor.visit(ast.parse(_source))
if class_visitor.class_node is None:
raise ValueError(f"class {class_name} is not found in file {file_path}")
return None
to_visit_node_for_func = class_visitor.class_node
else:
to_visit_node_for_func = ast.parse(_source)

visitor = FuncNodeVisitor()
visitor.visit(to_visit_node_for_func)
if not visitor.func_exist:
raise ValueError(
f"function {class_name if class_name else ''}{'.' if class_name else ''}{func_name} is not found in file {file_path}"
)
return None
return visitor.type_hints


Expand Down
Loading
Loading