dbt-metabase
dbt-metabase copied to clipboard
KeyError: 'fk_target_table' when when column has semantic type type/FK and has no tests
Hello,
I've got a KeyError: 'fk_target_table'
when propagating data from dbt table to Metabase.
This error occurs in two specific cases:
- A column in the the schema.yml has a semantic type equal to
type/FK
but it has not atests
section within it. - A column in the the schema.yml has a semantic type equal to
type/FK
but itstests
section contains adbt_utils.relationships_where
test within it.
Explicitly setting type/FK
is not supported, because there's no way to specify the target table. You can only set the relationship test and then it will implicitly apply type/FK
with the target table specified in your relationship test.
Hello @gouline,
Thank you very much for your rapid answer. That explains and solves the error in case 1: we need to use a relationship test.
For case 2, do you know if dbt-metabase recognize a test of the type dbt_utils.relationships_where
?
@gouline Is that a Metabase limitation? In the UI it's supported to make something a foreign key without specifying a target table. In the case of numeric IDs, e.g. 1
, 2
, 3
giving them a key type allows them to be used in the query builder as IDs. Without, the query builder assumes they're numbers and tries to bin them.
@heberaguilar Unfortunately, not currently. It has the same to
and field
fields though, so you could easily implement it here for the folder parser and here for the manifest parser.
@erika-e This is a dbt-metabase limitation, because it tries to be smart and infer your foreign key without explicitly specifying it. You could make the extraction of fk_target_table
and fk_target_field
optional here, if that's a use case that you need.