Skip to content

Commit f2f824e

Browse files
author
longshan.lu
committed
refactor: Simplify schema retrieval in LogicalPlan by consolidating schema methods and implementing table schema handling
1 parent c69996f commit f2f824e

File tree

1 file changed

+8
-18
lines changed
  • qurious/src/logical/plan

1 file changed

+8
-18
lines changed

qurious/src/logical/plan/mod.rs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use arrow::datatypes::SchemaRef;
2727

2828
use super::expr::{Column, LogicalExpr};
2929
use crate::common::table_relation::TableRelation;
30-
use crate::common::table_schema::TableSchemaRef;
30+
use crate::common::table_schema::{TableSchema, TableSchemaRef};
3131
use crate::common::transformed::{TransformNode, Transformed, TransformedResult, TreeNodeContainer, TreeNodeRecursion};
3232
use crate::error::Result;
3333

@@ -116,23 +116,8 @@ impl LogicalPlan {
116116
}
117117
}
118118

119-
// FIXME: remove this method when table schema is implemented
120119
pub fn schema(&self) -> SchemaRef {
121-
match self {
122-
LogicalPlan::Projection(p) => p.schema(),
123-
LogicalPlan::Filter(f) => f.schema(),
124-
LogicalPlan::Aggregate(a) => a.schema().arrow_schema(),
125-
LogicalPlan::TableScan(t) => t.schema(),
126-
LogicalPlan::EmptyRelation(e) => e.schema.clone(),
127-
LogicalPlan::CrossJoin(s) => s.schema(),
128-
LogicalPlan::SubqueryAlias(s) => s.schema(),
129-
LogicalPlan::Join(j) => j.schema(),
130-
LogicalPlan::Sort(s) => s.schema(),
131-
LogicalPlan::Limit(l) => l.schema(),
132-
LogicalPlan::Ddl(d) => d.schema(),
133-
LogicalPlan::Dml(d) => d.schema(),
134-
LogicalPlan::Values(v) => v.schema.clone(),
135-
}
120+
self.table_schema().arrow_schema()
136121
}
137122

138123
pub fn table_schema(&self) -> TableSchemaRef {
@@ -144,7 +129,12 @@ impl LogicalPlan {
144129
LogicalPlan::Projection(p) => p.schema.clone(),
145130
LogicalPlan::Join(j) => j.schema.clone(),
146131
LogicalPlan::Aggregate(a) => a.schema.clone(),
147-
_ => todo!("[{}] not implement table_schema", self),
132+
LogicalPlan::Sort(s) => s.input.table_schema(),
133+
LogicalPlan::Limit(l) => l.input.table_schema(),
134+
LogicalPlan::EmptyRelation(e) => Arc::new(TableSchema::from(e.schema.clone())),
135+
LogicalPlan::Values(v) => Arc::new(TableSchema::from(v.schema.clone())),
136+
LogicalPlan::Ddl(d) => Arc::new(TableSchema::from(d.schema())),
137+
LogicalPlan::Dml(d) => Arc::new(TableSchema::from(d.schema())),
148138
}
149139
}
150140

0 commit comments

Comments
 (0)