Skip to content

Commit

Permalink
refactor(cubesql): Simplify V1CubeMetaMeasureExt::get_sql_type
Browse files Browse the repository at this point in the history
  • Loading branch information
mcheshkov committed Aug 23, 2024
1 parent 861f13e commit a84d39d
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions rust/cubesql/cubesql/src/transport/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,24 @@ impl V1CubeMetaMeasureExt for CubeMetaMeasure {
}

fn get_sql_type(&self) -> ColumnType {
let from_type = match &self._type.to_lowercase().as_str() {
&"number" => ColumnType::Double,
&"boolean" => ColumnType::Boolean,
let self_type = self._type.to_lowercase();
let self_type = self_type.as_str();

let from_type = match self_type {
"number" => ColumnType::Double,
"boolean" => ColumnType::Boolean,
_ => ColumnType::String,
};

match &self.agg_type {
Some(agg_type) => match agg_type.as_str() {
"count" => ColumnType::Int64,
"countDistinct" => ColumnType::Int64,
"countDistinctApprox" => ColumnType::Int64,
"sum" => ColumnType::Double,
"avg" => ColumnType::Double,
"min" => ColumnType::Double,
"max" => ColumnType::Double,
"runningTotal" => ColumnType::Double,
_ => from_type,
},
match self.agg_type.as_deref() {
Some("count") => ColumnType::Int64,
Some("countDistinct") => ColumnType::Int64,
Some("countDistinctApprox") => ColumnType::Int64,
Some("sum") => ColumnType::Double,
Some("avg") => ColumnType::Double,
Some("min") => ColumnType::Double,
Some("max") => ColumnType::Double,
Some("runningTotal") => ColumnType::Double,
_ => from_type,
}
}
Expand Down

0 comments on commit a84d39d

Please sign in to comment.