Skip to content

Commit 88dca59

Browse files
committed
feat: use optimised logical plan for schema
1 parent b57d53e commit 88dca59

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/frontend/src/error.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,10 @@ pub enum Error {
346346
},
347347

348348
#[snafu(display("Failed to describe schema for given statement, source: {}", source))]
349-
DescribeStatement { source: query::error::Error },
349+
DescribeStatement {
350+
#[snafu(backtrace)]
351+
source: query::error::Error,
352+
},
350353
}
351354

352355
pub type Result<T> = std::result::Result<T, Error>;

src/query/src/datafusion.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,12 @@ impl QueryEngine for DatafusionQueryEngine {
104104
}
105105

106106
fn describe(&self, stmt: QueryStatement, query_ctx: QueryContextRef) -> Result<Schema> {
107-
self.statement_to_plan(stmt, query_ctx)?.schema()
107+
// TODO(sunng87): consider cache optmised logical plan between describe
108+
// and execute
109+
let plan = self.statement_to_plan(stmt, query_ctx)?;
110+
let mut ctx = QueryEngineContext::new(self.state.clone());
111+
let optimised_plan = self.optimize_logical_plan(&mut ctx, &plan)?;
112+
optimised_plan.schema()
108113
}
109114

110115
async fn execute(&self, plan: &LogicalPlan) -> Result<Output> {

0 commit comments

Comments
 (0)