Snowflake odities and ReplaceableObject

27 views
Skip to first unread message

Scott

unread,
Oct 11, 2019, 2:58:12 AM10/11/19
to sqlalchemy-alembic
I am using alembic with Snowflake.

In terms of DDL migrations I need to cater for SECURED VIEWS, it is pretty trivial to extend ReplaceableObject to deal with this.

The other thing I am finding is that Snowflake insists that DROP FUNCTION be provided with a list of the argument types along with the function name, so with a function:

    CREATE FUNCTION myfunc(TABLENAME VARCHAR)
    RETURNS VARCHAR
    ....

this does not work:

    DROP FUNCTION myfunc

I need to go

    DROP FUNCTION myfunc(VARCHAR)

But I cannot go

    DROP FUNCTION myfunc(TABLENAME VARCHAR)

So in terms of using ReplaceableObject, to CREATE I need:

ReplaceableObject(
    "myfunc(TABLENAME VARCHAR)",
    """
 RETURNS VARCHAR
LANGUAGE javascript
...

But to DROP I need:

ReplaceableObject(
    "myfunc(VARCHAR)",
    """
 RETURNS VARCHAR
LANGUAGE javascript
...

I can hack something together with a superclass, but though I would mention here in case someone has a cleaner solution.

Cheers, Scott

Mike Bayer

unread,
Oct 11, 2019, 10:04:29 AM10/11/19
to sqlalchem...@googlegroups.com
I think it would be simplest to use a regular expression to pull out the symbol names from the declared function in order to write out the DROP text.

Otherwise, just add additional arguments to ReplaceableObject.   It's a recipe so you should change it directly, I wouldn't create new superclasses or anything like that.    
--
You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alem...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages