gouline / dbt-metabase

dbt + Metabase integration
https://pypi.org/project/dbt-metabase/
MIT License
442 stars 63 forks source link

fix: circular foreign key reference #106

Closed joelluijmes closed 2 years ago

joelluijmes commented 2 years ago

The current parsing of depends_on assumes that there is always one record returning. However this might not always be the case.

In my instance, I have a model which has a self-reference (some sort of tree table, where the parent is the same entity). Due the self filtering, the set returns nothing -> list[0] yields key error, and the program crashes.

The proposed changes is a more generic fix in case the set returns zero items. The downside of this is that the self reference still doesn't show up in metabase. But I'm not to familiar with the manifest file to detect this, so open to suggestions or this quick fix.

Resolves #81