From e8b776c26e8a6a7d5202aba0ec26f13f29b43499 Mon Sep 17 00:00:00 2001 From: Dmitry Patsura Date: Fri, 18 Oct 2024 13:53:00 +0200 Subject: [PATCH 1/6] feat(api-gateway): Declare type field for CubeMeta --- packages/cubejs-api-gateway/openspec.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/cubejs-api-gateway/openspec.yml b/packages/cubejs-api-gateway/openspec.yml index 8b21b5dcc1715..bdeaa29d46f28 100644 --- a/packages/cubejs-api-gateway/openspec.yml +++ b/packages/cubejs-api-gateway/openspec.yml @@ -151,6 +151,7 @@ components: type: "object" required: - name + - type - measures - dimensions - segments @@ -159,6 +160,8 @@ components: type: "string" title: type: "string" + type: + $ref: "#/components/schemas/V1CubeMetaType" description: type: "string" measures: @@ -177,6 +180,11 @@ components: type: "array" items: $ref: "#/components/schemas/V1CubeMetaJoin" + V1CubeMetaType: + type: "string" + enum: + - "cube" + - "view" V1MetaResponse: type: "object" properties: From 3c40516a6db59abc9cb6db27fb9dc28f94cf865b Mon Sep 17 00:00:00 2001 From: Dmitry Patsura Date: Fri, 18 Oct 2024 14:00:19 +0200 Subject: [PATCH 2/6] chore(cubeclient): regenerate --- .../cubeclient/.openapi-generator/FILES | 1 + rust/cubesql/cubeclient/src/models/mod.rs | 2 ++ .../cubeclient/src/models/v1_cube_meta.rs | 4 +++ .../src/models/v1_cube_meta_dimension.rs | 6 ++-- .../src/models/v1_cube_meta_measure.rs | 6 ++-- .../src/models/v1_cube_meta_type.rs | 33 +++++++++++++++++++ 6 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 rust/cubesql/cubeclient/src/models/v1_cube_meta_type.rs diff --git a/rust/cubesql/cubeclient/.openapi-generator/FILES b/rust/cubesql/cubeclient/.openapi-generator/FILES index 77271cbe4bd13..9151da7ed16ac 100644 --- a/rust/cubesql/cubeclient/.openapi-generator/FILES +++ b/rust/cubesql/cubeclient/.openapi-generator/FILES @@ -7,6 +7,7 @@ src/models/v1_cube_meta_dimension_granularity.rs src/models/v1_cube_meta_join.rs src/models/v1_cube_meta_measure.rs src/models/v1_cube_meta_segment.rs +src/models/v1_cube_meta_type.rs src/models/v1_error.rs src/models/v1_load_request.rs src/models/v1_load_request_query.rs diff --git a/rust/cubesql/cubeclient/src/models/mod.rs b/rust/cubesql/cubeclient/src/models/mod.rs index 8d227ab6ffab8..276b1a0daae83 100644 --- a/rust/cubesql/cubeclient/src/models/mod.rs +++ b/rust/cubesql/cubeclient/src/models/mod.rs @@ -10,6 +10,8 @@ pub mod v1_cube_meta_measure; pub use self::v1_cube_meta_measure::V1CubeMetaMeasure; pub mod v1_cube_meta_segment; pub use self::v1_cube_meta_segment::V1CubeMetaSegment; +pub mod v1_cube_meta_type; +pub use self::v1_cube_meta_type::V1CubeMetaType; pub mod v1_error; pub use self::v1_error::V1Error; pub mod v1_load_request; diff --git a/rust/cubesql/cubeclient/src/models/v1_cube_meta.rs b/rust/cubesql/cubeclient/src/models/v1_cube_meta.rs index 141714e55588a..9ff347bcf9f30 100644 --- a/rust/cubesql/cubeclient/src/models/v1_cube_meta.rs +++ b/rust/cubesql/cubeclient/src/models/v1_cube_meta.rs @@ -14,6 +14,8 @@ pub struct V1CubeMeta { pub name: String, #[serde(rename = "title", skip_serializing_if = "Option::is_none")] pub title: Option, + #[serde(rename = "type")] + pub r#type: crate::models::V1CubeMetaType, #[serde(rename = "description", skip_serializing_if = "Option::is_none")] pub description: Option, #[serde(rename = "measures")] @@ -29,6 +31,7 @@ pub struct V1CubeMeta { impl V1CubeMeta { pub fn new( name: String, + r#type: crate::models::V1CubeMetaType, measures: Vec, dimensions: Vec, segments: Vec, @@ -36,6 +39,7 @@ impl V1CubeMeta { V1CubeMeta { name, title: None, + r#type, 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 e8d0bbe4af033..8990e05540738 100644 --- a/rust/cubesql/cubeclient/src/models/v1_cube_meta_dimension.rs +++ b/rust/cubesql/cubeclient/src/models/v1_cube_meta_dimension.rs @@ -15,17 +15,17 @@ pub struct V1CubeMetaDimension { #[serde(rename = "description", skip_serializing_if = "Option::is_none")] pub description: Option, #[serde(rename = "type")] - pub _type: String, + pub r#type: String, #[serde(rename = "granularities", skip_serializing_if = "Option::is_none")] pub granularities: Option>, } impl V1CubeMetaDimension { - pub fn new(name: String, _type: String) -> V1CubeMetaDimension { + pub fn new(name: String, r#type: String) -> V1CubeMetaDimension { V1CubeMetaDimension { name, description: None, - _type, + r#type, granularities: 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 9595e45cb3c50..57f1aa53a7301 100644 --- a/rust/cubesql/cubeclient/src/models/v1_cube_meta_measure.rs +++ b/rust/cubesql/cubeclient/src/models/v1_cube_meta_measure.rs @@ -17,18 +17,18 @@ pub struct V1CubeMetaMeasure { #[serde(rename = "description", skip_serializing_if = "Option::is_none")] pub description: Option, #[serde(rename = "type")] - pub _type: String, + pub r#type: String, #[serde(rename = "aggType", skip_serializing_if = "Option::is_none")] pub agg_type: Option, } impl V1CubeMetaMeasure { - pub fn new(name: String, _type: String) -> V1CubeMetaMeasure { + pub fn new(name: String, r#type: String) -> V1CubeMetaMeasure { V1CubeMetaMeasure { name, title: None, description: None, - _type, + r#type, agg_type: None, } } diff --git a/rust/cubesql/cubeclient/src/models/v1_cube_meta_type.rs b/rust/cubesql/cubeclient/src/models/v1_cube_meta_type.rs new file mode 100644 index 0000000000000..255f5bbd74d1f --- /dev/null +++ b/rust/cubesql/cubeclient/src/models/v1_cube_meta_type.rs @@ -0,0 +1,33 @@ +/* + * Cube.js + * + * Cube.js Swagger Schema + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum V1CubeMetaType { + #[serde(rename = "cube")] + Cube, + #[serde(rename = "view")] + View, +} + +impl ToString for V1CubeMetaType { + fn to_string(&self) -> String { + match self { + Self::Cube => String::from("cube"), + Self::View => String::from("view"), + } + } +} + +impl Default for V1CubeMetaType { + fn default() -> V1CubeMetaType { + Self::Cube + } +} From 379c9b1b2448e700e157a3210a89463e132e74e9 Mon Sep 17 00:00:00 2001 From: Dmitry Patsura Date: Fri, 18 Oct 2024 14:00:36 +0200 Subject: [PATCH 3/6] chore: fixes for cubesql --- .../src/compile/rewrite/rules/members.rs | 2 +- .../src/compile/rewrite/rules/old_split.rs | 4 +- rust/cubesql/cubesql/src/compile/test/mod.rs | 104 +++++++++--------- rust/cubesql/cubesql/src/transport/ctx.rs | 3 + rust/cubesql/cubesql/src/transport/ext.rs | 8 +- rust/cubesql/cubesql/src/transport/mod.rs | 1 + 6 files changed, 65 insertions(+), 57 deletions(-) diff --git a/rust/cubesql/cubesql/src/compile/rewrite/rules/members.rs b/rust/cubesql/cubesql/src/compile/rewrite/rules/members.rs index 79fa094a995ea..5ddcc8a3d68b1 100644 --- a/rust/cubesql/cubesql/src/compile/rewrite/rules/members.rs +++ b/rust/cubesql/cubesql/src/compile/rewrite/rules/members.rs @@ -1688,7 +1688,7 @@ impl MemberRules { .find_cube_with_name(time_dimension_name.split(".").next().unwrap()) { if let Some(time_dimension) = cube.dimensions.iter().find(|d| { - d._type == "time" && d.name.eq_ignore_ascii_case(&time_dimension_name) + d.r#type == "time" && d.name.eq_ignore_ascii_case(&time_dimension_name) }) { for granularity in var_iter!(egraph[subst[granularity_var]], LiteralExprValue) diff --git a/rust/cubesql/cubesql/src/compile/rewrite/rules/old_split.rs b/rust/cubesql/cubesql/src/compile/rewrite/rules/old_split.rs index 2b141f124ee75..2dcb93b0f93bb 100644 --- a/rust/cubesql/cubesql/src/compile/rewrite/rules/old_split.rs +++ b/rust/cubesql/cubesql/src/compile/rewrite/rules/old_split.rs @@ -5065,8 +5065,8 @@ impl OldSplitRules { meta.find_cube_by_column(&alias_to_cube, &column) { if let Some(dimension) = cube.lookup_dimension(&column.name) { - if is_time_dimension && dimension._type == "time" - || !is_time_dimension && dimension._type != "time" + if is_time_dimension && dimension.r#type == "time" + || !is_time_dimension && dimension.r#type != "time" { if let Some(expr_name) = original_expr_name(egraph, subst[arg_expr_var]) diff --git a/rust/cubesql/cubesql/src/compile/test/mod.rs b/rust/cubesql/cubesql/src/compile/test/mod.rs index 3b62d2f1ad564..35d8e5b8f6b2e 100644 --- a/rust/cubesql/cubesql/src/compile/test/mod.rs +++ b/rust/cubesql/cubesql/src/compile/test/mod.rs @@ -1,13 +1,5 @@ use std::{collections::HashMap, env, ops::Deref, sync::Arc}; -use crate::transport::{ - CubeMeta, CubeMetaDimension, CubeMetaJoin, CubeMetaMeasure, CubeMetaSegment, MetaContext, - TransportLoadRequestQuery, TransportLoadResponse, -}; -use async_trait::async_trait; -use datafusion::{arrow::datatypes::SchemaRef, dataframe::DataFrame as DFDataFrame}; -use uuid::Uuid; - use super::{convert_sql_to_cube_query, CompilationResult, QueryPlan}; use crate::{ compile::{ @@ -21,11 +13,16 @@ use crate::{ HttpAuthContext, ServerManager, Session, SessionManager, SqlAuthService, }, transport::{ - CubeStreamReceiver, LoadRequestMeta, SpanId, SqlGenerator, SqlResponse, SqlTemplates, - TransportService, + CubeMeta, CubeMetaDimension, CubeMetaJoin, CubeMetaMeasure, CubeMetaSegment, + CubeStreamReceiver, LoadRequestMeta, MetaContext, SpanId, SqlGenerator, SqlResponse, + SqlTemplates, TransportLoadRequestQuery, TransportLoadResponse, TransportService, }, CubeError, }; +use async_trait::async_trait; +use cubeclient::models::V1CubeMetaType; +use datafusion::{arrow::datatypes::SchemaRef, dataframe::DataFrame as DFDataFrame}; +use uuid::Uuid; pub mod rewrite_engine; #[cfg(test)] @@ -51,41 +48,42 @@ pub fn get_test_meta() -> Vec { name: "KibanaSampleDataEcommerce".to_string(), description: Some("Sample data for tracking eCommerce orders from Kibana".to_string()), title: None, + r#type: V1CubeMetaType::Cube, dimensions: vec![ CubeMetaDimension { name: "KibanaSampleDataEcommerce.order_date".to_string(), description: None, - _type: "time".to_string(), + r#type: "time".to_string(), granularities: None, }, CubeMetaDimension { name: "KibanaSampleDataEcommerce.last_mod".to_string(), description: None, - _type: "time".to_string(), + r#type: "time".to_string(), granularities: None, }, CubeMetaDimension { name: "KibanaSampleDataEcommerce.customer_gender".to_string(), description: Some("Customer gender".to_string()), - _type: "string".to_string(), + r#type: "string".to_string(), granularities: None, }, CubeMetaDimension { name: "KibanaSampleDataEcommerce.notes".to_string(), description: None, - _type: "string".to_string(), + r#type: "string".to_string(), granularities: None, }, CubeMetaDimension { name: "KibanaSampleDataEcommerce.taxful_total_price".to_string(), description: None, - _type: "number".to_string(), + r#type: "number".to_string(), granularities: None, }, CubeMetaDimension { name: "KibanaSampleDataEcommerce.has_subscription".to_string(), description: None, - _type: "boolean".to_string(), + r#type: "boolean".to_string(), granularities: None, }, ], @@ -94,42 +92,42 @@ pub fn get_test_meta() -> Vec { name: "KibanaSampleDataEcommerce.count".to_string(), title: None, description: Some("Events count".to_string()), - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("count".to_string()), }, CubeMetaMeasure { name: "KibanaSampleDataEcommerce.maxPrice".to_string(), title: None, description: None, - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("max".to_string()), }, CubeMetaMeasure { name: "KibanaSampleDataEcommerce.sumPrice".to_string(), title: None, description: None, - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("sum".to_string()), }, CubeMetaMeasure { name: "KibanaSampleDataEcommerce.minPrice".to_string(), title: None, description: None, - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("min".to_string()), }, CubeMetaMeasure { name: "KibanaSampleDataEcommerce.avgPrice".to_string(), title: None, description: None, - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("avg".to_string()), }, CubeMetaMeasure { name: "KibanaSampleDataEcommerce.countDistinct".to_string(), title: None, description: None, - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("countDistinct".to_string()), }, ], @@ -156,23 +154,24 @@ pub fn get_test_meta() -> Vec { name: "Logs".to_string(), description: None, title: None, + r#type: V1CubeMetaType::Cube, dimensions: vec![ CubeMetaDimension { name: "Logs.id".to_string(), description: None, - _type: "number".to_string(), + r#type: "number".to_string(), granularities: None, }, CubeMetaDimension { name: "Logs.read".to_string(), description: None, - _type: "boolean".to_string(), + r#type: "boolean".to_string(), granularities: None, }, CubeMetaDimension { name: "Logs.content".to_string(), description: None, - _type: "string".to_string(), + r#type: "string".to_string(), granularities: None, }, ], @@ -181,14 +180,14 @@ pub fn get_test_meta() -> Vec { name: "Logs.agentCount".to_string(), title: None, description: None, - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("countDistinct".to_string()), }, CubeMetaMeasure { name: "Logs.agentCountApprox".to_string(), title: None, description: None, - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("countDistinctApprox".to_string()), }, ], @@ -202,12 +201,13 @@ pub fn get_test_meta() -> Vec { name: "NumberCube".to_string(), description: None, title: None, + r#type: V1CubeMetaType::Cube, dimensions: vec![], measures: vec![CubeMetaMeasure { name: "NumberCube.someNumber".to_string(), title: None, description: None, - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("number".to_string()), }], segments: vec![], @@ -217,18 +217,19 @@ pub fn get_test_meta() -> Vec { name: "WideCube".to_string(), description: None, title: None, + r#type: V1CubeMetaType::Cube, dimensions: (0..100) .map(|i| CubeMetaDimension { name: format!("WideCube.dim{}", i), description: None, - _type: "number".to_string(), + r#type: "number".to_string(), granularities: None, }) .collect(), measures: (0..100) .map(|i| CubeMetaMeasure { name: format!("WideCube.measure{}", i), - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("number".to_string()), title: None, description: None, @@ -239,35 +240,35 @@ pub fn get_test_meta() -> Vec { name: "KibanaSampleDataEcommerce.count".to_string(), title: None, description: None, - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("count".to_string()), }, CubeMetaMeasure { name: "KibanaSampleDataEcommerce.maxPrice".to_string(), title: None, description: None, - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("max".to_string()), }, CubeMetaMeasure { name: "KibanaSampleDataEcommerce.minPrice".to_string(), title: None, description: None, - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("min".to_string()), }, CubeMetaMeasure { name: "KibanaSampleDataEcommerce.avgPrice".to_string(), title: None, description: None, - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("avg".to_string()), }, CubeMetaMeasure { name: "KibanaSampleDataEcommerce.countDistinct".to_string(), title: None, description: None, - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("countDistinct".to_string()), }, ] @@ -281,25 +282,26 @@ pub fn get_test_meta() -> Vec { name: "MultiTypeCube".to_string(), description: Some("Test cube with a little bit of everything".to_string()), title: None, + r#type: V1CubeMetaType::Cube, dimensions: (0..10) .flat_map(|i| { [ CubeMetaDimension { name: format!("MultiTypeCube.dim_num{}", i), description: Some(format!("Test numeric dimention {i}")), - _type: "number".to_string(), + r#type: "number".to_string(), granularities: None, }, CubeMetaDimension { name: format!("MultiTypeCube.dim_str{}", i), description: Some(format!("Test string dimention {i}")), - _type: "string".to_string(), + r#type: "string".to_string(), granularities: None, }, CubeMetaDimension { name: format!("MultiTypeCube.dim_date{}", i), description: Some(format!("Test time dimention {i}")), - _type: "time".to_string(), + r#type: "time".to_string(), granularities: None, }, ] @@ -310,21 +312,21 @@ pub fn get_test_meta() -> Vec { [ CubeMetaMeasure { name: format!("MultiTypeCube.measure_num{}", i), - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("number".to_string()), title: None, description: Some(format!("Test number measure {i}")), }, CubeMetaMeasure { name: format!("MultiTypeCube.measure_str{}", i), - _type: "string".to_string(), + r#type: "string".to_string(), agg_type: Some("max".to_string()), title: None, description: Some(format!("Test max(string) measure {i}")), }, CubeMetaMeasure { name: format!("MultiTypeCube.measure_date{}", i), - _type: "time".to_string(), + r#type: "time".to_string(), agg_type: Some("max".to_string()), title: None, description: Some(format!("Test max(time) measure {i}")), @@ -337,35 +339,35 @@ pub fn get_test_meta() -> Vec { name: "MultiTypeCube.count".to_string(), title: None, description: Some("Test count measure".to_string()), - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("count".to_string()), }, CubeMetaMeasure { name: "MultiTypeCube.maxPrice".to_string(), title: None, description: Some("Test maxPrice measure".to_string()), - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("max".to_string()), }, CubeMetaMeasure { name: "MultiTypeCube.minPrice".to_string(), title: None, description: Some("Test minPrice measure".to_string()), - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("min".to_string()), }, CubeMetaMeasure { name: "MultiTypeCube.avgPrice".to_string(), title: None, description: Some("Test avgPrice measure".to_string()), - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("avg".to_string()), }, CubeMetaMeasure { name: "MultiTypeCube.countDistinct".to_string(), title: None, description: Some("Test countDistinct measure".to_string()), - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("countDistinct".to_string()), }, ] @@ -383,12 +385,13 @@ pub fn get_string_cube_meta() -> Vec { name: "StringCube".to_string(), description: None, title: None, + r#type: V1CubeMetaType::Cube, dimensions: vec![], measures: vec![CubeMetaMeasure { name: "StringCube.someString".to_string(), title: None, description: None, - _type: "string".to_string(), + r#type: "string".to_string(), agg_type: Some("string".to_string()), }], segments: vec![], @@ -401,27 +404,28 @@ pub fn get_sixteen_char_member_cube() -> Vec { name: "SixteenChar".to_string(), description: None, title: None, + r#type: V1CubeMetaType::Cube, dimensions: vec![], measures: vec![ CubeMetaMeasure { name: "SixteenChar.sixteen_charchar".to_string(), title: None, description: None, - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("sum".to_string()), }, CubeMetaMeasure { name: "SixteenChar.sixteen_charchar_foo".to_string(), title: None, description: None, - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("avg".to_string()), }, CubeMetaMeasure { name: "SixteenChar.sixteen_charchar_bar".to_string(), title: None, description: None, - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("count".to_string()), }, ], diff --git a/rust/cubesql/cubesql/src/transport/ctx.rs b/rust/cubesql/cubesql/src/transport/ctx.rs index a3ceee2a4c7f4..ff1389c1736df 100644 --- a/rust/cubesql/cubesql/src/transport/ctx.rs +++ b/rust/cubesql/cubesql/src/transport/ctx.rs @@ -220,6 +220,7 @@ impl MetaContext { #[cfg(test)] mod tests { use super::*; + use crate::transport::CubeMetaType; #[test] fn test_find_tables() { @@ -228,6 +229,7 @@ mod tests { name: "test1".to_string(), description: None, title: None, + r#type: CubeMetaType::Cube, dimensions: vec![], measures: vec![], segments: vec![], @@ -237,6 +239,7 @@ mod tests { name: "test2".to_string(), description: None, title: None, + r#type: CubeMetaType::Cube, dimensions: vec![], measures: vec![], segments: vec![], diff --git a/rust/cubesql/cubesql/src/transport/ext.rs b/rust/cubesql/cubesql/src/transport/ext.rs index 98e2d823f64d4..f9b35687a16ef 100644 --- a/rust/cubesql/cubesql/src/transport/ext.rs +++ b/rust/cubesql/cubesql/src/transport/ext.rs @@ -58,7 +58,7 @@ impl V1CubeMetaMeasureExt for CubeMetaMeasure { } fn get_sql_type(&self) -> ColumnType { - let from_type = match &self._type.to_lowercase().as_str() { + let from_type = match &self.r#type.to_lowercase().as_str() { &"number" => ColumnType::Double, &"boolean" => ColumnType::Boolean, _ => ColumnType::String, @@ -111,7 +111,7 @@ impl V1CubeMetaDimensionExt for CubeMetaDimension { } fn is_time(&self) -> bool { - self._type.to_lowercase().eq("time") + self.r#type.to_lowercase().eq("time") } fn sql_can_be_null(&self) -> bool { @@ -120,7 +120,7 @@ impl V1CubeMetaDimensionExt for CubeMetaDimension { } fn get_sql_type(&self) -> ColumnType { - match self._type.to_lowercase().as_str() { + match self.r#type.to_lowercase().as_str() { "time" => ColumnType::Timestamp, "number" => ColumnType::Double, "boolean" => ColumnType::Boolean, @@ -354,7 +354,7 @@ impl V1CubeMetaExt for CubeMeta { .iter() .find(|m| m.name.eq_ignore_ascii_case(member_name)) { - return Some(match dimension._type.as_str() { + return Some(match dimension.r#type.as_str() { "number" => MemberType::Number, "boolean" => MemberType::Boolean, "string" => MemberType::String, diff --git a/rust/cubesql/cubesql/src/transport/mod.rs b/rust/cubesql/cubesql/src/transport/mod.rs index f57211ae206f8..4955124693637 100644 --- a/rust/cubesql/cubesql/src/transport/mod.rs +++ b/rust/cubesql/cubesql/src/transport/mod.rs @@ -4,6 +4,7 @@ pub(crate) mod service; // Re-export types to minimise version maintenance for crate users such as cloud pub type CubeMeta = cubeclient::models::V1CubeMeta; +pub type CubeMetaType = cubeclient::models::V1CubeMetaType; pub type CubeMetaDimension = cubeclient::models::V1CubeMetaDimension; pub type CubeMetaMeasure = cubeclient::models::V1CubeMetaMeasure; pub type CubeMetaSegment = cubeclient::models::V1CubeMetaSegment; From c62e16bd1ccc7c56efcfc652e755cb9178f9d578 Mon Sep 17 00:00:00 2001 From: Dmitry Patsura Date: Fri, 18 Oct 2024 14:14:59 +0200 Subject: [PATCH 4/6] chore: fix build --- packages/cubejs-api-gateway/openspec.yml | 1 + rust/cubesql/cubeclient/src/models/v1_cube_meta_type.rs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/cubejs-api-gateway/openspec.yml b/packages/cubejs-api-gateway/openspec.yml index bdeaa29d46f28..722decf358e92 100644 --- a/packages/cubejs-api-gateway/openspec.yml +++ b/packages/cubejs-api-gateway/openspec.yml @@ -182,6 +182,7 @@ components: $ref: "#/components/schemas/V1CubeMetaJoin" V1CubeMetaType: type: "string" + description: Type of cube enum: - "cube" - "view" diff --git a/rust/cubesql/cubeclient/src/models/v1_cube_meta_type.rs b/rust/cubesql/cubeclient/src/models/v1_cube_meta_type.rs index 255f5bbd74d1f..94cdb84e03dbb 100644 --- a/rust/cubesql/cubeclient/src/models/v1_cube_meta_type.rs +++ b/rust/cubesql/cubeclient/src/models/v1_cube_meta_type.rs @@ -8,7 +8,9 @@ * Generated by: https://openapi-generator.tech */ -/// +/// V1CubeMetaType : Type of cube + +/// Type of cube #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] pub enum V1CubeMetaType { #[serde(rename = "cube")] From 53e238be0869b26250a2ce58d83ad8e47bb11ed7 Mon Sep 17 00:00:00 2001 From: Dmitry Patsura Date: Fri, 18 Oct 2024 14:23:35 +0200 Subject: [PATCH 5/6] chore: fix build --- rust/cubesql/cubeclient/src/lib.rs | 4 ++++ rust/cubesql/cubesql/benches/large_model.rs | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/rust/cubesql/cubeclient/src/lib.rs b/rust/cubesql/cubeclient/src/lib.rs index fc22e4e4b9d1a..60e95930302aa 100644 --- a/rust/cubesql/cubeclient/src/lib.rs +++ b/rust/cubesql/cubeclient/src/lib.rs @@ -1,3 +1,7 @@ +// Open spec generator generates ToString methods for enums, let's disable clippy rule as quick +// workaround. TODO: Use new one open spec generator? +#![allow(clippy::to_string_trait_impl)] + #[macro_use] extern crate serde_derive; diff --git a/rust/cubesql/cubesql/benches/large_model.rs b/rust/cubesql/cubesql/benches/large_model.rs index 2c91a16ce2914..0fd0887b82fbd 100644 --- a/rust/cubesql/cubesql/benches/large_model.rs +++ b/rust/cubesql/cubesql/benches/large_model.rs @@ -2,7 +2,7 @@ use std::{env::set_var, sync::Arc, time::Duration}; use criterion::{criterion_group, criterion_main, Criterion}; -use cubeclient::models::{V1CubeMeta, V1CubeMetaDimension, V1CubeMetaMeasure}; +use cubeclient::models::{V1CubeMeta, V1CubeMetaDimension, V1CubeMetaMeasure, V1CubeMetaType}; use cubesql::{ compile::test::{ rewrite_engine::{ @@ -72,19 +72,20 @@ pub fn get_large_model_test_meta(dims: usize) -> Vec { name: cube_name.clone(), description: None, title: None, + r#type: V1CubeMetaType::Cube, measures: vec![ V1CubeMetaMeasure { name: format!("{}.count", cube_name), title: None, description: None, - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("count".to_string()), }, V1CubeMetaMeasure { name: format!("{}.sum", cube_name), title: None, description: None, - _type: "number".to_string(), + r#type: "number".to_string(), agg_type: Some("sum".to_string()), }, ], @@ -92,7 +93,7 @@ pub fn get_large_model_test_meta(dims: usize) -> Vec { .map(|n| V1CubeMetaDimension { name: format!("{}.n{}", cube_name, n), description: None, - _type: "number".to_string(), + r#type: "number".to_string(), granularities: None, }) .collect(), From 367924be66d76aa5f23205e324cc1a9fdc25148f Mon Sep 17 00:00:00 2001 From: Dmitry Patsura Date: Fri, 18 Oct 2024 14:37:33 +0200 Subject: [PATCH 6/6] chore: fix build --- packages/cubejs-backend-native/test/meta.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/cubejs-backend-native/test/meta.js b/packages/cubejs-backend-native/test/meta.js index bae52bf168ae8..d5cad0adc3691 100644 --- a/packages/cubejs-backend-native/test/meta.js +++ b/packages/cubejs-backend-native/test/meta.js @@ -5,6 +5,7 @@ module.exports = { { name: 'KibanaSampleDataEcommerce', title: 'Ecommerce', + type: 'cube', measures: [ { name: 'KibanaSampleDataEcommerce.count', @@ -126,6 +127,7 @@ module.exports = { { name: 'Logs', title: 'Logs', + type: 'cube', measures: [ { name: 'Logs.count',