This is an automated email from the ASF dual-hosted git repository.
agrove pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new fa0f372 ARROW-8736: [Rust] [DataFusion] Table API should provide a
schema() method
fa0f372 is described below
commit fa0f372e31de7bae2a59549e113d685edab8daf4
Author: Kyle McCarthy <[email protected]>
AuthorDate: Mon Jun 8 21:39:30 2020 -0600
ARROW-8736: [Rust] [DataFusion] Table API should provide a schema() method
Closes #7371 from kyle-mccarthy/ARROW-8736
Authored-by: Kyle McCarthy <[email protected]>
Signed-off-by: Andy Grove <[email protected]>
---
rust/datafusion/src/execution/table_impl.rs | 6 ++++++
rust/datafusion/src/table.rs | 4 ++++
2 files changed, 10 insertions(+)
diff --git a/rust/datafusion/src/execution/table_impl.rs
b/rust/datafusion/src/execution/table_impl.rs
index c1dbb77..facb83f 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 API
pub 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.rs
index c60c1df..1c1e982 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;
}