Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api-gateway): OpenAPI - declare type field for Cube #8837

Merged
merged 6 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/cubejs-api-gateway/openspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ components:
type: "object"
required:
- name
- type
- measures
- dimensions
- segments
Expand All @@ -159,6 +160,8 @@ components:
type: "string"
title:
type: "string"
type:
$ref: "#/components/schemas/V1CubeMetaType"
description:
type: "string"
measures:
Expand All @@ -177,6 +180,11 @@ components:
type: "array"
items:
$ref: "#/components/schemas/V1CubeMetaJoin"
V1CubeMetaType:
type: "string"
enum:
- "cube"
- "view"
V1MetaResponse:
type: "object"
properties:
Expand Down
1 change: 1 addition & 0 deletions rust/cubesql/cubeclient/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions rust/cubesql/cubeclient/src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions rust/cubesql/cubeclient/src/models/v1_cube_meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
pub name: String,
#[serde(rename = "title", skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "type")]
pub r#type: crate::models::V1CubeMetaType,
#[serde(rename = "description", skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "measures")]
Expand All @@ -29,13 +31,15 @@
impl V1CubeMeta {
pub fn new(
name: String,
r#type: crate::models::V1CubeMetaType,

Check warning on line 34 in rust/cubesql/cubeclient/src/models/v1_cube_meta.rs

View check run for this annotation

Codecov / codecov/patch

rust/cubesql/cubeclient/src/models/v1_cube_meta.rs#L34

Added line #L34 was not covered by tests
measures: Vec<crate::models::V1CubeMetaMeasure>,
dimensions: Vec<crate::models::V1CubeMetaDimension>,
segments: Vec<crate::models::V1CubeMetaSegment>,
) -> V1CubeMeta {
V1CubeMeta {
name,
title: None,
r#type,

Check warning on line 42 in rust/cubesql/cubeclient/src/models/v1_cube_meta.rs

View check run for this annotation

Codecov / codecov/patch

rust/cubesql/cubeclient/src/models/v1_cube_meta.rs#L42

Added line #L42 was not covered by tests
description: None,
measures,
dimensions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
#[serde(rename = "description", skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "type")]
pub _type: String,
pub r#type: String,
#[serde(rename = "granularities", skip_serializing_if = "Option::is_none")]
pub granularities: Option<Vec<crate::models::V1CubeMetaDimensionGranularity>>,
}

impl V1CubeMetaDimension {
pub fn new(name: String, _type: String) -> V1CubeMetaDimension {
pub fn new(name: String, r#type: String) -> V1CubeMetaDimension {

Check warning on line 24 in rust/cubesql/cubeclient/src/models/v1_cube_meta_dimension.rs

View check run for this annotation

Codecov / codecov/patch

rust/cubesql/cubeclient/src/models/v1_cube_meta_dimension.rs#L24

Added line #L24 was not covered by tests
V1CubeMetaDimension {
name,
description: None,
_type,
r#type,

Check warning on line 28 in rust/cubesql/cubeclient/src/models/v1_cube_meta_dimension.rs

View check run for this annotation

Codecov / codecov/patch

rust/cubesql/cubeclient/src/models/v1_cube_meta_dimension.rs#L28

Added line #L28 was not covered by tests
granularities: None,
}
}
Expand Down
6 changes: 3 additions & 3 deletions rust/cubesql/cubeclient/src/models/v1_cube_meta_measure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
#[serde(rename = "description", skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "type")]
pub _type: String,
pub r#type: String,
#[serde(rename = "aggType", skip_serializing_if = "Option::is_none")]
pub agg_type: Option<String>,
}

impl V1CubeMetaMeasure {
pub fn new(name: String, _type: String) -> V1CubeMetaMeasure {
pub fn new(name: String, r#type: String) -> V1CubeMetaMeasure {

Check warning on line 26 in rust/cubesql/cubeclient/src/models/v1_cube_meta_measure.rs

View check run for this annotation

Codecov / codecov/patch

rust/cubesql/cubeclient/src/models/v1_cube_meta_measure.rs#L26

Added line #L26 was not covered by tests
V1CubeMetaMeasure {
name,
title: None,
description: None,
_type,
r#type,

Check warning on line 31 in rust/cubesql/cubeclient/src/models/v1_cube_meta_measure.rs

View check run for this annotation

Codecov / codecov/patch

rust/cubesql/cubeclient/src/models/v1_cube_meta_measure.rs#L31

Added line #L31 was not covered by tests
agg_type: None,
}
}
Expand Down
33 changes: 33 additions & 0 deletions rust/cubesql/cubeclient/src/models/v1_cube_meta_type.rs
Original file line number Diff line number Diff line change
@@ -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"),

Check warning on line 24 in rust/cubesql/cubeclient/src/models/v1_cube_meta_type.rs

View check run for this annotation

Codecov / codecov/patch

rust/cubesql/cubeclient/src/models/v1_cube_meta_type.rs#L21-L24

Added lines #L21 - L24 were not covered by tests
}
}

Check warning on line 26 in rust/cubesql/cubeclient/src/models/v1_cube_meta_type.rs

View check run for this annotation

Codecov / codecov/patch

rust/cubesql/cubeclient/src/models/v1_cube_meta_type.rs#L26

Added line #L26 was not covered by tests
}

impl Default for V1CubeMetaType {
fn default() -> V1CubeMetaType {
Self::Cube
}

Check warning on line 32 in rust/cubesql/cubeclient/src/models/v1_cube_meta_type.rs

View check run for this annotation

Codecov / codecov/patch

rust/cubesql/cubeclient/src/models/v1_cube_meta_type.rs#L30-L32

Added lines #L30 - L32 were not covered by tests
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions rust/cubesql/cubesql/src/compile/rewrite/rules/old_split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5065,8 +5065,8 @@
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"

Check warning on line 5069 in rust/cubesql/cubesql/src/compile/rewrite/rules/old_split.rs

View check run for this annotation

Codecov / codecov/patch

rust/cubesql/cubesql/src/compile/rewrite/rules/old_split.rs#L5068-L5069

Added lines #L5068 - L5069 were not covered by tests
{
if let Some(expr_name) =
original_expr_name(egraph, subst[arg_expr_var])
Expand Down
Loading
Loading