-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f62b46b
commit 698a5f8
Showing
22 changed files
with
765 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,27 @@ | ||
use super::{Schema, Select, Union}; | ||
use super::{Schema, Select, TimeSeria, Union}; | ||
use crate::planner::sql_templates::PlanSqlTemplates; | ||
use cubenativeutils::CubeError; | ||
use std::rc::Rc; | ||
|
||
pub enum QueryPlan { | ||
Select(Rc<Select>), | ||
Union(Rc<Union>), | ||
TimeSeria(Rc<TimeSeria>), | ||
} | ||
|
||
impl QueryPlan { | ||
pub fn make_schema(&self, self_alias: Option<String>) -> Schema { | ||
match self { | ||
QueryPlan::Select(select) => select.make_schema(self_alias), | ||
QueryPlan::Union(union) => union.make_schema(self_alias), | ||
QueryPlan::TimeSeria(seria) => seria.make_schema(self_alias), | ||
} | ||
} | ||
pub fn to_sql(&self, templates: &PlanSqlTemplates) -> Result<String, CubeError> { | ||
match self { | ||
QueryPlan::Select(s) => s.to_sql(templates), | ||
QueryPlan::Union(u) => u.to_sql(templates), | ||
QueryPlan::TimeSeria(seria) => seria.to_sql(templates), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use super::{Schema, SchemaColumn, Select, Union}; | ||
use crate::planner::sql_templates::PlanSqlTemplates; | ||
use cubenativeutils::CubeError; | ||
use std::rc::Rc; | ||
|
||
pub struct TimeSeria { | ||
pub time_dimension_name: String, | ||
pub from_date: Option<String>, | ||
pub to_date: Option<String>, | ||
pub seria: Vec<Vec<String>>, | ||
} | ||
|
||
impl TimeSeria { | ||
pub fn make_schema(&self, self_alias: Option<String>) -> Schema { | ||
let column = SchemaColumn::new( | ||
self_alias, | ||
format!("from_date"), | ||
self.time_dimension_name.clone(), | ||
); | ||
Schema::new(vec![column], vec![]) | ||
} | ||
|
||
pub fn to_sql(&self, templates: &PlanSqlTemplates) -> Result<String, CubeError> { | ||
templates.time_seria_select( | ||
self.from_date.clone(), | ||
self.to_date.clone(), | ||
self.seria.clone(), | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.