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

Unable to set TABLE() return type #99

Closed
AndreiTapai opened this issue Apr 19, 2024 · 5 comments
Closed

Unable to set TABLE() return type #99

AndreiTapai opened this issue Apr 19, 2024 · 5 comments

Comments

@AndreiTapai
Copy link

Describe the bug
When declaring a procedure I would like to be able to set the return type to TABLE() since I do not know the return schema before the procedure executes. Currently I get an error.

Expected behavior
Compiles appropriately.

See Snowflake docs: https://docs.snowflake.com/en/developer-guide/stored-procedure/stored-procedures-snowflake-scripting

Attach log
ValueError: Could not parse data type string [TABLE()]

Attach YAML config (if applicable)

arguments:
  my_arg: VARCHAR(16777216)

returns: TABLE()

body: !include sql/my_sql.sql

Any help would be appreciated!

@littleK0i
Copy link
Owner

littleK0i commented Apr 19, 2024

In order to return TABLE(), please use an alternative syntax, which is similar to table columns:

returns:
   col1: NUMBER(38,0)
   col2: VARCHAR(255)

It is documented, but probably not very clear. Hmm.. maybe I should add an explicit warning to output about this.

@littleK0i
Copy link
Owner

Ah, it is about TABLE() without names and types. Seems like a new feature.

Initially you may try this syntax:

returns: {}

If it does not work, I'll update the code to take this use case into account.

@AndreiTapai
Copy link
Author

That seems to work. Though it is not very intuitive. Not sure how it could be expressed better. Maybe just documenting it is enough.

@littleK0i
Copy link
Owner

I'll add test and note in documentation with the next update.

Thank you for pointing this out.

@littleK0i
Copy link
Owner

Updated documentation for PROCEDURE object type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants