Skip to content

Can't drop tables with dependent objects during table version swap #205

@andrewcstewart

Description

@andrewcstewart

Hi there. I'm trying to figure out if the following issue is something I can handle at the datamill-co/target-postgres side or the dbt side of the equation.

I'm using Meltano to run a tap-mongodb to target-postgres pipe, followed by some dbt transforms. On the first run it works fine, but on subsequent runs I get the following error from the target:

target-postgres       | psycopg2.errors.DependentObjectsStillExist: cannot drop table tap_mongodb.foobar__old because other objects depend on it
target-postgres       | DETAIL:  view analytics.stg_foobar depends on table tap_mongodb.foobar__old
target-postgres       | HINT:  Use DROP ... CASCADE to drop the dependent objects too.
target-postgres       | 
target-postgres       | CRITICAL ('foobar - Exception activating table version 1617612127282', DependentObjectsStillExist('cannot drop table tap_mongodb.foobar__old because other objects depend on it\nDETAIL:  view analytics.stg_foobar depends on table tap_mongodb.foobar__old\nHINT:  Use DROP ... CASCADE to drop the dependent objects too.\n'))

I believe that target-postgres is saying here that it cannot drop the old table during table-switching because the views created by dbt are linked to it. I was looking into late binding views in dbt, but I'm not sure if that config option only applies to redshift.

Would it be appropriate for target-postgres to be using DROP ... CASCADE in these instances?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions