fix: resolve optimization issue for extended query

This commit is contained in:
Ning Sun
2026-03-17 19:40:05 +08:00
parent c6f1ef8aec
commit 07ae4369f9
3 changed files with 12 additions and 27 deletions

3
Cargo.lock generated
View File

@@ -9619,8 +9619,7 @@ dependencies = [
[[package]]
name = "pgwire"
version = "0.38.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89d5e5a60d3f6e40c91f6a2a7f8d09665e636272bd5611977253559b6651aabb"
source = "git+https://github.com/sunng87/pgwire?rev=26ee9805c433bc56262c6075b8c12f9c9e132364#26ee9805c433bc56262c6075b8c12f9c9e132364"
dependencies = [
"async-trait",
"base64 0.22.1",

View File

@@ -345,6 +345,7 @@ datafusion-datasource = { git = "https://github.com/GreptimeTeam/datafusion.git"
datafusion-sql = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "02b82535e0160c4545667f36a03e1ff9d1d2e51f" }
datafusion-substrait = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "02b82535e0160c4545667f36a03e1ff9d1d2e51f" }
sqlparser = { git = "https://github.com/GreptimeTeam/sqlparser-rs.git", rev = "2aefa08a8d69c96eec2d6d6703598a009bba6e4c" } # on branch v0.61.x
pgwire = { git = "https://github.com/sunng87/pgwire", rev = "26ee9805c433bc56262c6075b8c12f9c9e132364" }
[profile.release]
debug = 1

View File

@@ -444,32 +444,17 @@ impl QueryEngine for DatafusionQueryEngine {
async fn describe(
&self,
plan: LogicalPlan,
query_ctx: QueryContextRef,
_query_ctx: QueryContextRef,
) -> Result<DescribeResult> {
let ctx = self.engine_context(query_ctx);
if let Ok(optimised_plan) = self.optimize(&ctx, &plan) {
let schema = optimised_plan
.schema()
.clone()
.try_into()
.context(ConvertSchemaSnafu)?;
Ok(DescribeResult {
schema,
logical_plan: optimised_plan,
})
} else {
// Table's like those in information_schema cannot be optimized when
// it contains parameters. So we fallback to original plans.
let schema = plan
.schema()
.clone()
.try_into()
.context(ConvertSchemaSnafu)?;
Ok(DescribeResult {
schema,
logical_plan: plan,
})
}
let schema = plan
.schema()
.clone()
.try_into()
.context(ConvertSchemaSnafu)?;
Ok(DescribeResult {
schema,
logical_plan: plan,
})
}
async fn execute(&self, plan: LogicalPlan, query_ctx: QueryContextRef) -> Result<Output> {