diff --git a/packages/buster-cli/src/assets/templates/buster_model.yml b/packages/buster-cli/src/assets/templates/buster_model.yml index 10eafc612..dc2f47a1c 100644 --- a/packages/buster-cli/src/assets/templates/buster_model.yml +++ b/packages/buster-cli/src/assets/templates/buster_model.yml @@ -1,6 +1,6 @@ version: 2 -semantic_models: +models: - name: the_name_of_the_semantic_model ## Required description: same as always ## Optional model: ref('some_model') ## Required: the database identifier of the table/view/mv that this semantic model relates to. diff --git a/packages/buster-cli/src/utils/buster/types.rs b/packages/buster-cli/src/utils/buster/types.rs index 6a2b49d3f..f370c09d7 100644 --- a/packages/buster-cli/src/utils/buster/types.rs +++ b/packages/buster-cli/src/utils/buster/types.rs @@ -47,7 +47,7 @@ pub struct PostDatasetsColumnsRequest { #[derive(Debug, Serialize)] pub struct PostDatasetsEntityRelationshipsRequest { pub name: String, - pub expr: Vec, + pub expr: String, #[serde(rename = "type")] pub type_: String, } diff --git a/packages/buster-cli/src/utils/file/model_files.rs b/packages/buster-cli/src/utils/file/model_files.rs index 4db1668cc..0499d60d7 100644 --- a/packages/buster-cli/src/utils/file/model_files.rs +++ b/packages/buster-cli/src/utils/file/model_files.rs @@ -22,13 +22,12 @@ pub struct BusterModelObject { #[derive(Debug, Serialize, Deserialize)] pub struct BusterModel { pub version: i32, - pub semantic_models: Vec, + pub models: Vec, } #[derive(Debug, Serialize, Deserialize)] -pub struct SemanticModel { +pub struct Model { pub name: String, - pub defaults: ModelDefaults, pub description: String, pub model: Option, pub entities: Vec, @@ -36,11 +35,6 @@ pub struct SemanticModel { pub measures: Vec, } -#[derive(Debug, Serialize, Deserialize)] -pub struct ModelDefaults { - pub agg_time_dimension: String, -} - #[derive(Debug, Serialize, Deserialize)] pub struct Entity { pub name: String, @@ -121,7 +115,7 @@ pub async fn upload_model_files( // Iterate through each model object and the semantic models within. These are the datasets we want to create. for model in model_objects { - for semantic_model in model.model_file.semantic_models { + for semantic_model in model.model_file.models { let mut columns = Vec::new(); for column in semantic_model.dimensions { @@ -151,7 +145,7 @@ pub async fn upload_model_files( for entity in semantic_model.entities { entity_relationships.push(PostDatasetsEntityRelationshipsRequest { name: entity.name, - expr: vec![entity.expr], + expr: entity.expr, type_: entity.entity_type, }); } diff --git a/packages/buster-cli/tests/command_tests.rs b/packages/buster-cli/tests/command_tests.rs index 86d11b7f3..957d9fbe7 100644 --- a/packages/buster-cli/tests/command_tests.rs +++ b/packages/buster-cli/tests/command_tests.rs @@ -2,7 +2,7 @@ fn test_convert_buster_to_dbt_model() { let buster_yaml = r#" version: 2 -semantic_models: +models: - name: test_model aliases: ["alias1"] entities: @@ -23,7 +23,7 @@ semantic_models: "#; let dbt_yaml = convert_buster_to_dbt_model(buster_yaml).unwrap(); - + // The converted YAML shouldn't contain Buster-specific fields assert!(!dbt_yaml.contains("aliases")); assert!(!dbt_yaml.contains("join_type"));