littleK0i / SnowDDL

Declarative database change management tool for Snowflake
Apache License 2.0
105 stars 28 forks source link

Unable to set TABLE() return type #99

Closed AndreiTapai closed 7 months ago

AndreiTapai commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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

Thank you for pointing this out.

littleK0i commented 7 months ago

Updated documentation for PROCEDURE object type.