File should return Model error when creating models + relationships

I get a "“File should return Model” error when relationships are defined below the model like this :

Model ecommerce_order_items{....}
Relationship rel_category {
  type: 'many_to_one'
  from: ref('ecommerce_order_items','category_id')
  to: ref('ecommerce_products','category_code')
}

When relationships are declared before the model everything works :

Relationship rel_category {
  type: 'many_to_one'
  from: ref('ecommerce_order_items','category_id')
  to: ref('ecommerce_products','category_code')
}
Model ecommerce_order_items{....}
1 Like

Hi @dacou,

Currently, we use the last object in the file as model/dataset.
Thus, when you position your Model { } on top, Relationship { } at the bottom, we will interpret it as Relationship.

This brings quite a negative experience so we will improve it in the future, thank you so much for your contribution.

1 Like