Skip to content

Commit 825a2a4

Browse files
committed
chore(cubesql): QueryEngine - support custom metadata for QueryPlan
1 parent d81cf88 commit 825a2a4

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

rust/cubesql/cubesql/src/compile/plan.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,7 @@ pub enum QueryPlan {
4747
// Query will be executed via Data Fusion
4848
DataFusionSelect(LogicalPlan, DFSessionContext),
4949
// Query will be executed via DataFusion and saved to session
50-
CreateTempTable(
51-
LogicalPlan,
52-
DFSessionContext,
53-
String,
54-
Arc<TempTableManager>,
55-
),
50+
CreateTempTable(LogicalPlan, DFSessionContext, String, Arc<TempTableManager>),
5651
}
5752

5853
impl fmt::Debug for QueryPlan {
@@ -85,8 +80,9 @@ impl fmt::Debug for QueryPlan {
8580
impl QueryPlan {
8681
pub fn as_logical_plan(&self) -> LogicalPlan {
8782
match self {
88-
QueryPlan::DataFusionSelect(plan, _)
89-
| QueryPlan::CreateTempTable(plan, _, _, _) => plan.clone(),
83+
QueryPlan::DataFusionSelect(plan, _) | QueryPlan::CreateTempTable(plan, _, _, _) => {
84+
plan.clone()
85+
}
9086
QueryPlan::MetaOk(_, _) | QueryPlan::MetaTabular(_, _) => {
9187
panic!("This query doesnt have a plan, because it already has values for response")
9288
}
@@ -110,8 +106,7 @@ impl QueryPlan {
110106

111107
pub fn print(&self, pretty: bool) -> Result<String, CubeError> {
112108
match self {
113-
QueryPlan::DataFusionSelect(plan, _)
114-
| QueryPlan::CreateTempTable(plan, _, _, _) => {
109+
QueryPlan::DataFusionSelect(plan, _) | QueryPlan::CreateTempTable(plan, _, _, _) => {
115110
if pretty {
116111
Ok(plan.display_indent().to_string())
117112
} else {

rust/cubesql/cubesql/src/compile/query_engine.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,7 @@ pub trait QueryEngine {
253253
qtrace.set_best_plan_and_cube_scans(&rewrite_plan);
254254
}
255255

256-
Ok((
257-
QueryPlan::DataFusionSelect(
258-
rewrite_plan,
259-
ctx,
260-
),
261-
metadata
262-
))
256+
Ok((QueryPlan::DataFusionSelect(rewrite_plan, ctx), metadata))
263257
}
264258

265259
fn evaluate_wrapped_sql(
@@ -480,7 +474,8 @@ impl QueryEngine for SqlQueryEngine {
480474
stmt: &Self::AstStatementType,
481475
) -> Result<(LogicalPlan, Self::PlanMetadataType), DataFusionError> {
482476
let df_query_planner = SqlToRel::new_with_options(cube_ctx, true);
483-
let plan = df_query_planner.statement_to_plan(DFStatement::Statement(Box::new(stmt.clone())))?;
477+
let plan =
478+
df_query_planner.statement_to_plan(DFStatement::Statement(Box::new(stmt.clone())))?;
484479

485480
Ok((plan, ()))
486481
}

0 commit comments

Comments
 (0)