-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LogicalPlanBuilder
now uses TableSource
instead of TableProvider
#2569
Changes from all commits
a29799f
dadb0fc
f6bf0c7
77807f0
75039e3
1c52ac9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,6 @@ | |
|
||
//! This module provides a builder for creating LogicalPlans | ||
|
||
use crate::datasource::TableProvider; | ||
use crate::error::{DataFusionError, Result}; | ||
use crate::logical_expr::ExprSchemable; | ||
use crate::logical_plan::plan::{ | ||
|
@@ -41,11 +40,12 @@ use std::{ | |
use super::{Expr, JoinConstraint, JoinType, LogicalPlan, PlanType}; | ||
use crate::logical_plan::{ | ||
columnize_expr, exprlist_to_fields, normalize_col, normalize_cols, | ||
provider_as_source, rewrite_sort_cols_by_aggs, Column, CrossJoin, DFField, DFSchema, | ||
DFSchemaRef, Limit, Offset, Partitioning, Repartition, Values, | ||
rewrite_sort_cols_by_aggs, Column, CrossJoin, DFField, DFSchema, DFSchemaRef, Limit, | ||
Offset, Partitioning, Repartition, Values, | ||
}; | ||
|
||
use datafusion_common::ToDFSchema; | ||
use datafusion_expr::TableSource; | ||
|
||
/// Default table name for unnamed table | ||
pub const UNNAMED_TABLE: &str = "?table?"; | ||
|
@@ -191,16 +191,16 @@ impl LogicalPlanBuilder { | |
/// Convert a table provider into a builder with a TableScan | ||
pub fn scan( | ||
table_name: impl Into<String>, | ||
provider: Arc<dyn TableProvider>, | ||
table_source: Arc<dyn TableSource>, | ||
projection: Option<Vec<usize>>, | ||
) -> Result<Self> { | ||
Self::scan_with_filters(table_name, provider, projection, vec![]) | ||
Self::scan_with_filters(table_name, table_source, projection, vec![]) | ||
} | ||
|
||
/// Convert a table provider into a builder with a TableScan | ||
pub fn scan_with_filters( | ||
table_name: impl Into<String>, | ||
provider: Arc<dyn TableProvider>, | ||
table_source: Arc<dyn TableSource>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we could make the APIs a little (avoid having to call Untested:
Or add some other trait that would allow us to pass both I think we can always refine the API in a follow on PR |
||
projection: Option<Vec<usize>>, | ||
filters: Vec<Expr>, | ||
) -> Result<Self> { | ||
|
@@ -212,7 +212,7 @@ impl LogicalPlanBuilder { | |
)); | ||
} | ||
|
||
let schema = provider.schema(); | ||
let schema = table_source.schema(); | ||
|
||
let projected_schema = projection | ||
.as_ref() | ||
|
@@ -232,7 +232,7 @@ impl LogicalPlanBuilder { | |
|
||
let table_scan = LogicalPlan::TableScan(TableScan { | ||
table_name, | ||
source: provider_as_source(provider), | ||
source: table_source, | ||
projected_schema: Arc::new(projected_schema), | ||
projection, | ||
filters, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the main objective - removing one of the final dependencies from
LogicalPlanBuilder
to the "core"datafusion
crate.