@@ -71,24 +71,33 @@ impl std::fmt::Display for TableType {
71
71
}
72
72
}
73
73
74
- /// Access schema information and filter push-down capabilities .
74
+ /// Planning time information about a table .
75
75
///
76
- /// The TableSource trait is used during logical query planning and
77
- /// optimizations and provides a subset of the functionality of the
78
- /// `TableProvider` trait in the (core) `datafusion` crate. The `TableProvider`
79
- /// trait provides additional capabilities needed for physical query execution
80
- /// (such as the ability to perform a scan).
76
+ /// This trait is used during logical query planning and optimizations, and
77
+ /// provides a subset of the [`TableProvider`] trait, such as schema information
78
+ /// and filter push-down capabilities. The [`TableProvider`] trait provides
79
+ /// additional information needed for physical query execution, such as the
80
+ /// ability to perform a scan or insert data.
81
+ ///
82
+ /// # See Also:
83
+ ///
84
+ /// [`DefaultTableSource`] to go from [`TableProvider`], to `TableSource`
85
+ ///
86
+ /// # Rationale
81
87
///
82
88
/// The reason for having two separate traits is to avoid having the logical
83
89
/// plan code be dependent on the DataFusion execution engine. Some projects use
84
90
/// DataFusion's logical plans and have their own execution engine.
91
+ ///
92
+ /// [`TableProvider`]: https://docs.rs/datafusion/latest/datafusion/datasource/provider/trait.TableProvider.html
93
+ /// [`DefaultTableSource`]: https://docs.rs/datafusion/latest/datafusion/datasource/default_table_source/struct.DefaultTableSource.html
85
94
pub trait TableSource : Sync + Send {
86
95
fn as_any ( & self ) -> & dyn Any ;
87
96
88
97
/// Get a reference to the schema for this table
89
98
fn schema ( & self ) -> SchemaRef ;
90
99
91
- /// Get primary key indices, if one exists.
100
+ /// Get primary key indices, if any
92
101
fn constraints ( & self ) -> Option < & Constraints > {
93
102
None
94
103
}
@@ -110,6 +119,8 @@ pub trait TableSource: Sync + Send {
110
119
}
111
120
112
121
/// Get the Logical plan of this table provider, if available.
122
+ ///
123
+ /// For example, a view may have a logical plan, but a CSV file does not.
113
124
fn get_logical_plan ( & self ) -> Option < Cow < LogicalPlan > > {
114
125
None
115
126
}
0 commit comments