@@ -27,7 +27,7 @@ use arrow::datatypes::SchemaRef;
2727
2828use super :: expr:: { Column , LogicalExpr } ;
2929use crate :: common:: table_relation:: TableRelation ;
30- use crate :: common:: table_schema:: TableSchemaRef ;
30+ use crate :: common:: table_schema:: { TableSchema , TableSchemaRef } ;
3131use crate :: common:: transformed:: { TransformNode , Transformed , TransformedResult , TreeNodeContainer , TreeNodeRecursion } ;
3232use 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