ismaelhenzel
Valued Contributor

I totally agree. It’s a mess that DLT can't handle self-referential constraints. I’ve had to create some ugly workaround functions to get past this—like a function that tries to read the referenced table and returns an empty string if it throws an error; otherwise, it adds the constraint to the materialized view schema.

I really think this should be supported in declarative pipelines—something like add constraint fk IF table x EXISTS. Or, at the very least, allow ALTER MATERIALIZED VIEW to add constraints in a separate step.

DLT has some awesome features, like incremental processing in materialized views, but it misses details like this that make a huge difference when planning a migration.