From d5f4a3ca691c2910c1749e20820f934e1173448e Mon Sep 17 00:00:00 2001 From: Dmitry Patsura Date: Fri, 18 Oct 2024 17:04:13 +0200 Subject: [PATCH] feat: OpenAPI - declare meta field --- packages/cubejs-api-gateway/openspec.yml | 8 +++ rust/cubesql/cubeclient/DEVELOPMENT.md | 1 - .../cubeclient/src/models/v1_cube_meta.rs | 3 ++ .../src/models/v1_cube_meta_dimension.rs | 3 ++ .../src/models/v1_cube_meta_measure.rs | 3 ++ .../src/models/v1_cube_meta_segment.rs | 3 ++ rust/cubesql/cubesql/benches/large_model.rs | 4 ++ rust/cubesql/cubesql/src/compile/test/mod.rs | 49 +++++++++++++++++++ rust/cubesql/cubesql/src/transport/ctx.rs | 2 + 9 files changed, 75 insertions(+), 1 deletion(-) diff --git a/packages/cubejs-api-gateway/openspec.yml b/packages/cubejs-api-gateway/openspec.yml index 722decf358e92..51dfd77ffa45a 100644 --- a/packages/cubejs-api-gateway/openspec.yml +++ b/packages/cubejs-api-gateway/openspec.yml @@ -98,6 +98,8 @@ components: type: "string" shortTitle: type: "string" + meta: + type: "object" V1CubeMetaDimensionGranularity: type: "object" required: @@ -131,6 +133,8 @@ components: type: array items: $ref: "#/components/schemas/V1CubeMetaDimensionGranularity" + meta: + type: "object" V1CubeMetaMeasure: type: "object" required: @@ -147,6 +151,8 @@ components: type: "string" aggType: type: "string" + meta: + type: "object" V1CubeMeta: type: "object" required: @@ -162,6 +168,8 @@ components: type: "string" type: $ref: "#/components/schemas/V1CubeMetaType" + meta: + type: "object" description: type: "string" measures: diff --git a/rust/cubesql/cubeclient/DEVELOPMENT.md b/rust/cubesql/cubeclient/DEVELOPMENT.md index b1be79c554aae..ce5d1e194e695 100644 --- a/rust/cubesql/cubeclient/DEVELOPMENT.md +++ b/rust/cubesql/cubeclient/DEVELOPMENT.md @@ -33,6 +33,5 @@ The above command will also overwrite `src/apis/default_api.rs`, remember to do 1. Revert block for long polling in `load_v1()` 2. Revert block containing `tests` module -3. Rename fields from `r#type` to `_type` (TODO: we can use `--name-mappings type=_type` on new `openapi-generator`) Finally, run `cargo fmt` diff --git a/rust/cubesql/cubeclient/src/models/v1_cube_meta.rs b/rust/cubesql/cubeclient/src/models/v1_cube_meta.rs index 9ff347bcf9f30..08dafaa64f803 100644 --- a/rust/cubesql/cubeclient/src/models/v1_cube_meta.rs +++ b/rust/cubesql/cubeclient/src/models/v1_cube_meta.rs @@ -16,6 +16,8 @@ pub struct V1CubeMeta { pub title: Option, #[serde(rename = "type")] pub r#type: crate::models::V1CubeMetaType, + #[serde(rename = "meta", skip_serializing_if = "Option::is_none")] + pub meta: Option, #[serde(rename = "description", skip_serializing_if = "Option::is_none")] pub description: Option, #[serde(rename = "measures")] @@ -40,6 +42,7 @@ impl V1CubeMeta { name, title: None, r#type, + meta: None, description: None, measures, dimensions, diff --git a/rust/cubesql/cubeclient/src/models/v1_cube_meta_dimension.rs b/rust/cubesql/cubeclient/src/models/v1_cube_meta_dimension.rs index 8990e05540738..e48e3fd30bec3 100644 --- a/rust/cubesql/cubeclient/src/models/v1_cube_meta_dimension.rs +++ b/rust/cubesql/cubeclient/src/models/v1_cube_meta_dimension.rs @@ -18,6 +18,8 @@ pub struct V1CubeMetaDimension { pub r#type: String, #[serde(rename = "granularities", skip_serializing_if = "Option::is_none")] pub granularities: Option>, + #[serde(rename = "meta", skip_serializing_if = "Option::is_none")] + pub meta: Option, } impl V1CubeMetaDimension { @@ -27,6 +29,7 @@ impl V1CubeMetaDimension { description: None, r#type, granularities: None, + meta: None, } } } diff --git a/rust/cubesql/cubeclient/src/models/v1_cube_meta_measure.rs b/rust/cubesql/cubeclient/src/models/v1_cube_meta_measure.rs index 57f1aa53a7301..b05992a289247 100644 --- a/rust/cubesql/cubeclient/src/models/v1_cube_meta_measure.rs +++ b/rust/cubesql/cubeclient/src/models/v1_cube_meta_measure.rs @@ -20,6 +20,8 @@ pub struct V1CubeMetaMeasure { pub r#type: String, #[serde(rename = "aggType", skip_serializing_if = "Option::is_none")] pub agg_type: Option, + #[serde(rename = "meta", skip_serializing_if = "Option::is_none")] + pub meta: Option, } impl V1CubeMetaMeasure { @@ -30,6 +32,7 @@ impl V1CubeMetaMeasure { description: None, r#type, agg_type: None, + meta: None, } } } diff --git a/rust/cubesql/cubeclient/src/models/v1_cube_meta_segment.rs b/rust/cubesql/cubeclient/src/models/v1_cube_meta_segment.rs index 01888ff1e5c8b..89410c34eac87 100644 --- a/rust/cubesql/cubeclient/src/models/v1_cube_meta_segment.rs +++ b/rust/cubesql/cubeclient/src/models/v1_cube_meta_segment.rs @@ -18,6 +18,8 @@ pub struct V1CubeMetaSegment { pub description: Option, #[serde(rename = "shortTitle")] pub short_title: String, + #[serde(rename = "meta", skip_serializing_if = "Option::is_none")] + pub meta: Option, } impl V1CubeMetaSegment { @@ -27,6 +29,7 @@ impl V1CubeMetaSegment { title, description: None, short_title, + meta: None, } } } diff --git a/rust/cubesql/cubesql/benches/large_model.rs b/rust/cubesql/cubesql/benches/large_model.rs index 0fd0887b82fbd..f8fb0f293044b 100644 --- a/rust/cubesql/cubesql/benches/large_model.rs +++ b/rust/cubesql/cubesql/benches/large_model.rs @@ -80,6 +80,7 @@ pub fn get_large_model_test_meta(dims: usize) -> Vec { description: None, r#type: "number".to_string(), agg_type: Some("count".to_string()), + meta: None, }, V1CubeMetaMeasure { name: format!("{}.sum", cube_name), @@ -87,6 +88,7 @@ pub fn get_large_model_test_meta(dims: usize) -> Vec { description: None, r#type: "number".to_string(), agg_type: Some("sum".to_string()), + meta: None, }, ], dimensions: (1..=dims) @@ -95,10 +97,12 @@ pub fn get_large_model_test_meta(dims: usize) -> Vec { description: None, r#type: "number".to_string(), granularities: None, + meta: None, }) .collect(), segments: vec![], joins: None, + meta: None, }] } diff --git a/rust/cubesql/cubesql/src/compile/test/mod.rs b/rust/cubesql/cubesql/src/compile/test/mod.rs index 35d8e5b8f6b2e..045bc610dadcd 100644 --- a/rust/cubesql/cubesql/src/compile/test/mod.rs +++ b/rust/cubesql/cubesql/src/compile/test/mod.rs @@ -55,36 +55,42 @@ pub fn get_test_meta() -> Vec { description: None, r#type: "time".to_string(), granularities: None, + meta: None, }, CubeMetaDimension { name: "KibanaSampleDataEcommerce.last_mod".to_string(), description: None, r#type: "time".to_string(), granularities: None, + meta: None, }, CubeMetaDimension { name: "KibanaSampleDataEcommerce.customer_gender".to_string(), description: Some("Customer gender".to_string()), r#type: "string".to_string(), granularities: None, + meta: None, }, CubeMetaDimension { name: "KibanaSampleDataEcommerce.notes".to_string(), description: None, r#type: "string".to_string(), granularities: None, + meta: None, }, CubeMetaDimension { name: "KibanaSampleDataEcommerce.taxful_total_price".to_string(), description: None, r#type: "number".to_string(), granularities: None, + meta: None, }, CubeMetaDimension { name: "KibanaSampleDataEcommerce.has_subscription".to_string(), description: None, r#type: "boolean".to_string(), granularities: None, + meta: None, }, ], measures: vec![ @@ -94,6 +100,7 @@ pub fn get_test_meta() -> Vec { description: Some("Events count".to_string()), r#type: "number".to_string(), agg_type: Some("count".to_string()), + meta: None, }, CubeMetaMeasure { name: "KibanaSampleDataEcommerce.maxPrice".to_string(), @@ -101,6 +108,7 @@ pub fn get_test_meta() -> Vec { description: None, r#type: "number".to_string(), agg_type: Some("max".to_string()), + meta: None, }, CubeMetaMeasure { name: "KibanaSampleDataEcommerce.sumPrice".to_string(), @@ -108,6 +116,7 @@ pub fn get_test_meta() -> Vec { description: None, r#type: "number".to_string(), agg_type: Some("sum".to_string()), + meta: None, }, CubeMetaMeasure { name: "KibanaSampleDataEcommerce.minPrice".to_string(), @@ -115,6 +124,7 @@ pub fn get_test_meta() -> Vec { description: None, r#type: "number".to_string(), agg_type: Some("min".to_string()), + meta: None, }, CubeMetaMeasure { name: "KibanaSampleDataEcommerce.avgPrice".to_string(), @@ -122,6 +132,7 @@ pub fn get_test_meta() -> Vec { description: None, r#type: "number".to_string(), agg_type: Some("avg".to_string()), + meta: None, }, CubeMetaMeasure { name: "KibanaSampleDataEcommerce.countDistinct".to_string(), @@ -129,6 +140,7 @@ pub fn get_test_meta() -> Vec { description: None, r#type: "number".to_string(), agg_type: Some("countDistinct".to_string()), + meta: None, }, ], segments: vec![ @@ -137,18 +149,21 @@ pub fn get_test_meta() -> Vec { title: "Ecommerce Male".to_string(), description: Some("Male users segment".to_string()), short_title: "Male".to_string(), + meta: None, }, CubeMetaSegment { name: "KibanaSampleDataEcommerce.is_female".to_string(), title: "Ecommerce Female".to_string(), description: None, short_title: "Female".to_string(), + meta: None, }, ], joins: Some(vec![CubeMetaJoin { name: "Logs".to_string(), relationship: "belongsTo".to_string(), }]), + meta: None, }, CubeMeta { name: "Logs".to_string(), @@ -161,18 +176,21 @@ pub fn get_test_meta() -> Vec { description: None, r#type: "number".to_string(), granularities: None, + meta: None, }, CubeMetaDimension { name: "Logs.read".to_string(), description: None, r#type: "boolean".to_string(), granularities: None, + meta: None, }, CubeMetaDimension { name: "Logs.content".to_string(), description: None, r#type: "string".to_string(), granularities: None, + meta: None, }, ], measures: vec![ @@ -182,6 +200,7 @@ pub fn get_test_meta() -> Vec { description: None, r#type: "number".to_string(), agg_type: Some("countDistinct".to_string()), + meta: None, }, CubeMetaMeasure { name: "Logs.agentCountApprox".to_string(), @@ -189,6 +208,7 @@ pub fn get_test_meta() -> Vec { description: None, r#type: "number".to_string(), agg_type: Some("countDistinctApprox".to_string()), + meta: None, }, ], segments: vec![], @@ -196,6 +216,7 @@ pub fn get_test_meta() -> Vec { name: "NumberCube".to_string(), relationship: "belongsTo".to_string(), }]), + meta: None, }, CubeMeta { name: "NumberCube".to_string(), @@ -209,9 +230,11 @@ pub fn get_test_meta() -> Vec { description: None, r#type: "number".to_string(), agg_type: Some("number".to_string()), + meta: None, }], segments: vec![], joins: None, + meta: None, }, CubeMeta { name: "WideCube".to_string(), @@ -224,6 +247,7 @@ pub fn get_test_meta() -> Vec { description: None, r#type: "number".to_string(), granularities: None, + meta: None, }) .collect(), measures: (0..100) @@ -233,6 +257,7 @@ pub fn get_test_meta() -> Vec { agg_type: Some("number".to_string()), title: None, description: None, + meta: None, }) .chain( vec![ @@ -242,6 +267,7 @@ pub fn get_test_meta() -> Vec { description: None, r#type: "number".to_string(), agg_type: Some("count".to_string()), + meta: None, }, CubeMetaMeasure { name: "KibanaSampleDataEcommerce.maxPrice".to_string(), @@ -249,6 +275,7 @@ pub fn get_test_meta() -> Vec { description: None, r#type: "number".to_string(), agg_type: Some("max".to_string()), + meta: None, }, CubeMetaMeasure { name: "KibanaSampleDataEcommerce.minPrice".to_string(), @@ -256,6 +283,7 @@ pub fn get_test_meta() -> Vec { description: None, r#type: "number".to_string(), agg_type: Some("min".to_string()), + meta: None, }, CubeMetaMeasure { name: "KibanaSampleDataEcommerce.avgPrice".to_string(), @@ -263,6 +291,7 @@ pub fn get_test_meta() -> Vec { description: None, r#type: "number".to_string(), agg_type: Some("avg".to_string()), + meta: None, }, CubeMetaMeasure { name: "KibanaSampleDataEcommerce.countDistinct".to_string(), @@ -270,6 +299,7 @@ pub fn get_test_meta() -> Vec { description: None, r#type: "number".to_string(), agg_type: Some("countDistinct".to_string()), + meta: None, }, ] .into_iter(), @@ -277,6 +307,7 @@ pub fn get_test_meta() -> Vec { .collect(), segments: Vec::new(), joins: Some(Vec::new()), + meta: None, }, CubeMeta { name: "MultiTypeCube".to_string(), @@ -291,18 +322,21 @@ pub fn get_test_meta() -> Vec { description: Some(format!("Test numeric dimention {i}")), r#type: "number".to_string(), granularities: None, + meta: None, }, CubeMetaDimension { name: format!("MultiTypeCube.dim_str{}", i), description: Some(format!("Test string dimention {i}")), r#type: "string".to_string(), granularities: None, + meta: None, }, CubeMetaDimension { name: format!("MultiTypeCube.dim_date{}", i), description: Some(format!("Test time dimention {i}")), r#type: "time".to_string(), granularities: None, + meta: None, }, ] }) @@ -316,6 +350,7 @@ pub fn get_test_meta() -> Vec { agg_type: Some("number".to_string()), title: None, description: Some(format!("Test number measure {i}")), + meta: None, }, CubeMetaMeasure { name: format!("MultiTypeCube.measure_str{}", i), @@ -323,6 +358,7 @@ pub fn get_test_meta() -> Vec { agg_type: Some("max".to_string()), title: None, description: Some(format!("Test max(string) measure {i}")), + meta: None, }, CubeMetaMeasure { name: format!("MultiTypeCube.measure_date{}", i), @@ -330,6 +366,7 @@ pub fn get_test_meta() -> Vec { agg_type: Some("max".to_string()), title: None, description: Some(format!("Test max(time) measure {i}")), + meta: None, }, ] }) @@ -341,6 +378,7 @@ pub fn get_test_meta() -> Vec { description: Some("Test count measure".to_string()), r#type: "number".to_string(), agg_type: Some("count".to_string()), + meta: None, }, CubeMetaMeasure { name: "MultiTypeCube.maxPrice".to_string(), @@ -348,6 +386,7 @@ pub fn get_test_meta() -> Vec { description: Some("Test maxPrice measure".to_string()), r#type: "number".to_string(), agg_type: Some("max".to_string()), + meta: None, }, CubeMetaMeasure { name: "MultiTypeCube.minPrice".to_string(), @@ -355,6 +394,7 @@ pub fn get_test_meta() -> Vec { description: Some("Test minPrice measure".to_string()), r#type: "number".to_string(), agg_type: Some("min".to_string()), + meta: None, }, CubeMetaMeasure { name: "MultiTypeCube.avgPrice".to_string(), @@ -362,6 +402,7 @@ pub fn get_test_meta() -> Vec { description: Some("Test avgPrice measure".to_string()), r#type: "number".to_string(), agg_type: Some("avg".to_string()), + meta: None, }, CubeMetaMeasure { name: "MultiTypeCube.countDistinct".to_string(), @@ -369,6 +410,7 @@ pub fn get_test_meta() -> Vec { description: Some("Test countDistinct measure".to_string()), r#type: "number".to_string(), agg_type: Some("countDistinct".to_string()), + meta: None, }, ] .into_iter(), @@ -376,6 +418,7 @@ pub fn get_test_meta() -> Vec { .collect(), segments: Vec::new(), joins: Some(Vec::new()), + meta: None, }, ] } @@ -393,9 +436,11 @@ pub fn get_string_cube_meta() -> Vec { description: None, r#type: "string".to_string(), agg_type: Some("string".to_string()), + meta: None, }], segments: vec![], joins: None, + meta: None, }] } @@ -413,6 +458,7 @@ pub fn get_sixteen_char_member_cube() -> Vec { description: None, r#type: "number".to_string(), agg_type: Some("sum".to_string()), + meta: None, }, CubeMetaMeasure { name: "SixteenChar.sixteen_charchar_foo".to_string(), @@ -420,6 +466,7 @@ pub fn get_sixteen_char_member_cube() -> Vec { description: None, r#type: "number".to_string(), agg_type: Some("avg".to_string()), + meta: None, }, CubeMetaMeasure { name: "SixteenChar.sixteen_charchar_bar".to_string(), @@ -427,10 +474,12 @@ pub fn get_sixteen_char_member_cube() -> Vec { description: None, r#type: "number".to_string(), agg_type: Some("count".to_string()), + meta: None, }, ], segments: vec![], joins: None, + meta: None, }] } diff --git a/rust/cubesql/cubesql/src/transport/ctx.rs b/rust/cubesql/cubesql/src/transport/ctx.rs index ff1389c1736df..9033eef2d42ca 100644 --- a/rust/cubesql/cubesql/src/transport/ctx.rs +++ b/rust/cubesql/cubesql/src/transport/ctx.rs @@ -234,6 +234,7 @@ mod tests { measures: vec![], segments: vec![], joins: None, + meta: None, }, CubeMeta { name: "test2".to_string(), @@ -244,6 +245,7 @@ mod tests { measures: vec![], segments: vec![], joins: None, + meta: None, }, ];