Relationship syntax

(This feature is currently in active development. Please reach out if you want to become beta tester)

Relationship syntax definition

Relationship syntax defines relationships among related Data models. The relationship can be defined inside a model file or directly inside the dataset file

To define relationship, you need to specify:

  • Relationship type
  • The dimension used as join field between two related models

For the relationship to be functional in the dataset, you need to also specify the configuration of the relationship (active status and filter direction)

Relationship syntax

// Relationship full form defined in dataset file
RelationshipConfig {
rel: Relationship {
type: 'many_to_one | one_to_one'
from: ref('model_name','dimension_name')
to: ref('model_name','dimension_name')
}
active: true | false
filter_direction: 'two_way | one_to_many'
}
// Relationship short form defined in dataset file, relationship type > is many_to_one
rel(rel_expr: model_a.field_name > model_b.field_name, active: true, direction: 'two_way')
// Relationship short form defined in dataset file, relationship type - is one_to_one
rel(rel_expr: model_a.field_name - model_b.field_name, active: true, direction: 'two_way')
// Relationship defined in model file
Relationship relationship_name {
type: 'many_to_one | one_to_one'
from: ref('model_name','dimension_name')
to: ref('model_name','dimension_name')
}
// Relationship imported from model file to dataset file
import '../path/to/file/store/relationship_file' { relationship_name }
RelationshipConfig {
rel: relationship_name
active: true | false
filter_direction: 'two_way | one_to_many'
}

Parameter definition

Relationship

Parameter nameDescription
typeDefine relationship type (whether it's many_to_one, one_to_one or one_to_many)
fromSpecify the dimension in from parameter
toSpecify the dimension in to parameter

Relationship config

Parameter nameDescription
relDefine relationship that the config will be applied to
activeDetermine should the current relationship be active in dataset
directionDetermine the filter direction (whether it's two_way or one_to_many)