Apache DataFusion SQL Query Engine
ARROW-8736: [Rust] [DataFusion] Table API should provide a schema() method
Kyle McCarthye7f71565c1fb
diff --git a/rust/datafusion/src/execution/table_impl.rs b/rust/datafusion/src/execution/table_impl.rsindex c1dbb77407..facb83fecf 100644--- a/rust/datafusion/src/execution/table_impl.rs+++ b/rust/datafusion/src/execution/table_impl.rs@@ -26,6 +26,7 @@ use crate::execution::context::ExecutionContext;use crate::logicalplan::{Expr, LogicalPlan};use crate::logicalplan::{LogicalPlanBuilder, ScalarValue};use crate::table::*;+use arrow::datatypes::Schema;/// Implementation of Table APIpub struct TableImpl {@@ -131,6 +132,11 @@ impl Table for TableImpl {) -> Result<Vec<RecordBatch>> {ctx.collect_plan(&self.plan.clone(), batch_size)}++ /// Returns the schema from the logical plan+ fn schema(&self) -> &Schema {+ self.plan.schema().as_ref()+ }}impl TableImpl {diff --git a/rust/datafusion/src/table.rs b/rust/datafusion/src/table.rsindex c60c1dfa03..1c1e982a32 100644--- a/rust/datafusion/src/table.rs+++ b/rust/datafusion/src/table.rs@@ -22,6 +22,7 @@ use crate::arrow::record_batch::RecordBatch;use crate::error::Result;use crate::execution::context::ExecutionContext;use crate::logicalplan::{Expr, LogicalPlan};+use arrow::datatypes::Schema;use std::sync::Arc;/// Table is an abstraction of a logical query plan@@ -72,4 +73,7 @@ pub trait Table {ctx: &mut ExecutionContext,batch_size: usize,) -> Result<Vec<RecordBatch>>;++ /// Returns the schema+ fn schema(&self) -> &Schema;}