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-1230490: Allow Snowpark Function to define returns as name-type list #894

Open
kokorin opened this issue Mar 12, 2024 · 2 comments
Open
Labels
enhancement New feature or request snowpark

Comments

@kokorin
Copy link
Contributor

kokorin commented Mar 12, 2024

Description

We are investigating usage of Snow CLI 2.1.0 in our project in which we have UDTF defined.
Right now returns property of Snowflake Function definition has str type. So we have to use a workaround defining returns: "table (id int, name string)".

I think it may be useful to allow name-type list to be specified the same way as for signature property:

...
returns:
  - name: id
    type: int
  - name: name
    type: string
...

Context

No response

@github-actions github-actions bot changed the title Allow Snowpark Function to define returns as name-type list SNOW-1230490: Allow Snowpark Function to define returns as name-type list Mar 12, 2024
@sfc-gh-turbaszek
Copy link
Collaborator

Thanks for the proposal @kokorin! Happy to brainstorm on that one. Will simply changing the returns to list be enough? I have a feeling we would need to consider something like

returns:
   return_type: table
   columns:
       - name: "foo"
          type: "string"

returns:
   return_type: value
   type: "string"

What do you think?

@sfc-gh-turbaszek sfc-gh-turbaszek added enhancement New feature or request snowpark labels Mar 14, 2024
@kokorin
Copy link
Contributor Author

kokorin commented Mar 14, 2024

@sfc-gh-turbaszek to be honest return_type is confusing especially in second case. May be it could be better to have another top-level list in snowflake.yml:

definition_version: 1
snowpark:
  functions: 
    - name: my_udf
      # other props
      returns: string
  table_functions: 
    - name: my_udtf
      # other props
      returns: 
        - name: id
          type: int
        - name: name
          type: string
  procedures: [ ... ]

In that case it will be possible to validate signature.

Apart from that it can be useful to have more strict differentiation between UDF and UDTF:

definition_version: 1
snowpark:
  functions: 
    - name: my_udf
      # other props
      returns: string
    - name: my_udtf
      # other props
      returns_columns: 
        - name: id
          type: int
        - name: name
          type: string
  procedures: [ ... ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request snowpark
Projects
None yet
Development

No branches or pull requests

2 participants