Skip to content
Merged
Changes from all 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
28 changes: 17 additions & 11 deletions rust/cubesql/cubesql/src/compile/query_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ pub trait QueryEngine {
&self,
cube_ctx: &CubeContext,
stmt: &Self::AstStatementType,
span_id: Option<Arc<SpanId>>,
query_planning_id: Option<Uuid>,
) -> Result<(LogicalPlan, Self::PlanMetadataType), DataFusionError>;

fn sanitize_statement(&self, stmt: &Self::AstStatementType) -> Self::AstStatementType;
Expand Down Expand Up @@ -122,18 +124,20 @@ pub trait QueryEngine {
let ctx = self.create_session_ctx(state.clone())?;
let cube_ctx = self.create_cube_ctx(state.clone(), meta.clone(), ctx.clone())?;

let (plan, metadata) = self.create_logical_plan(&cube_ctx, &stmt).map_err(|err| {
let message = format!("Initial planning error: {}", err,);
let meta = Some(HashMap::from([
("query".to_string(), stmt.to_string()),
(
"sanitizedQuery".to_string(),
self.sanitize_statement(&stmt).to_string(),
),
]));
let (plan, metadata) = self
.create_logical_plan(&cube_ctx, &stmt, span_id.clone(), Some(query_planning_id))
.map_err(|err| {
let message = format!("Initial planning error: {}", err,);
let meta = Some(HashMap::from([
("query".to_string(), stmt.to_string()),
(
"sanitizedQuery".to_string(),
self.sanitize_statement(&stmt).to_string(),
),
]));

CompilationError::internal(message).with_meta(meta)
})?;
CompilationError::internal(message).with_meta(meta)
})?;

let mut optimized_plan = plan;
// ctx.optimize(&plan).map_err(|err| {
Expand Down Expand Up @@ -567,6 +571,8 @@ impl QueryEngine for SqlQueryEngine {
&self,
cube_ctx: &CubeContext,
stmt: &Self::AstStatementType,
_span_id: Option<Arc<SpanId>>,
_query_planning_id: Option<Uuid>,
) -> Result<(LogicalPlan, Self::PlanMetadataType), DataFusionError> {
let df_query_planner = SqlToRel::new_with_options(cube_ctx, true);
let plan =
Expand Down
Loading