pub struct ListingTableConfig {
pub table_paths: Vec<ListingTableUrl>,
pub file_schema: Option<SchemaRef>,
pub options: Option<ListingOptions>,
/* private fields */
}Expand description
Configuration for creating a crate::ListingTable
§Schema Evolution Support
This configuration supports schema evolution through the optional
PhysicalExprAdapterFactory. You might want to override the default factory when you need:
- Type coercion requirements: When you need custom logic for converting between different Arrow data types (e.g., Int32 ↔ Int64, Utf8 ↔ LargeUtf8)
- Column mapping: You need to map columns with a legacy name to a new name
- Custom handling of missing columns: By default they are filled in with nulls, but you may e.g. want to fill them in with
0or"".
Fields§
§table_paths: Vec<ListingTableUrl>Paths on the ObjectStore for creating crate::ListingTable.
They should share the same schema and object store.
file_schema: Option<SchemaRef>Optional SchemaRef for the to be created crate::ListingTable.
See details on ListingTableConfig::with_schema
options: Option<ListingOptions>Optional ListingOptions for the to be created crate::ListingTable.
See details on ListingTableConfig::with_listing_options
Implementations§
Source§impl ListingTableConfig
impl ListingTableConfig
Sourcepub fn new(table_path: ListingTableUrl) -> Self
pub fn new(table_path: ListingTableUrl) -> Self
Creates new ListingTableConfig for reading the specified URL
Sourcepub fn new_with_multi_paths(table_paths: Vec<ListingTableUrl>) -> Self
pub fn new_with_multi_paths(table_paths: Vec<ListingTableUrl>) -> Self
Creates new ListingTableConfig with multiple table paths.
See ListingTableConfigExt::infer_options for details on what happens with multiple paths
Sourcepub fn schema_source(&self) -> SchemaSource
pub fn schema_source(&self) -> SchemaSource
Returns the source of the schema for this configuration
Sourcepub fn with_schema(self, schema: SchemaRef) -> Self
pub fn with_schema(self, schema: SchemaRef) -> Self
Set the schema for the overall crate::ListingTable
crate::ListingTable will automatically coerce, when possible, the schema
for individual files to match this schema.
If a schema is not provided, it is inferred using
Self::infer_schema.
If the schema is provided, it must contain only the fields in the file without the table partitioning columns.
§Example: Specifying Table Schema
let schema = Arc::new(Schema::new(vec![
Field::new("id", DataType::Int64, false),
Field::new("name", DataType::Utf8, true),
]));
let config = ListingTableConfig::new(table_paths)
.with_listing_options(listing_options) // Set options first
.with_schema(schema); // Then set schemaSourcepub fn with_listing_options(self, listing_options: ListingOptions) -> Self
pub fn with_listing_options(self, listing_options: ListingOptions) -> Self
Add listing_options to ListingTableConfig
If not provided, format and other options are inferred via
ListingTableConfigExt::infer_options.
§Example: Configuring Parquet Files with Custom Options
let options = ListingOptions::new(Arc::new(ParquetFormat::default()))
.with_file_extension(".parquet")
.with_collect_stat(true);
let config = ListingTableConfig::new(table_paths).with_listing_options(options);
// Configure file format and optionsSourcepub fn infer_file_extension_and_compression_type(
path: &str,
) -> Result<(String, Option<String>)>
pub fn infer_file_extension_and_compression_type( path: &str, ) -> Result<(String, Option<String>)>
Returns a tuple of (file_extension, optional compression_extension)
For example a path ending with blah.test.csv.gz returns ("csv", Some("gz"))
For example a path ending with blah.test.csv returns ("csv", None)
Sourcepub async fn infer_schema(self, state: &dyn Session) -> Result<Self>
pub async fn infer_schema(self, state: &dyn Session) -> Result<Self>
Infer the SchemaRef based on table_paths.
This method infers the table schema using the first table_path.
See ListingOptions::infer_schema for more details
§Errors
- if
self.optionsis not set. SeeSelf::with_listing_options
Sourcepub async fn infer_partitions_from_path(
self,
state: &dyn Session,
) -> Result<Self>
pub async fn infer_partitions_from_path( self, state: &dyn Session, ) -> Result<Self>
Infer the partition columns from table_paths.
§Errors
- if
self.optionsis not set. SeeSelf::with_listing_options
Sourcepub fn with_expr_adapter_factory(
self,
expr_adapter_factory: Arc<dyn PhysicalExprAdapterFactory>,
) -> Self
pub fn with_expr_adapter_factory( self, expr_adapter_factory: Arc<dyn PhysicalExprAdapterFactory>, ) -> Self
Set the PhysicalExprAdapterFactory for the crate::ListingTable
The expression adapter factory is used to create physical expression adapters that can handle schema evolution and type conversions when evaluating expressions with different schemas than the table schema.
Sourcepub fn with_schema_adapter_factory(
self,
_schema_adapter_factory: Arc<dyn SchemaAdapterFactory>,
) -> Self
👎Deprecated since 52.0.0: SchemaAdapterFactory has been removed. Use with_expr_adapter_factory and PhysicalExprAdapterFactory instead. See upgrading.md for more details.
pub fn with_schema_adapter_factory( self, _schema_adapter_factory: Arc<dyn SchemaAdapterFactory>, ) -> Self
Deprecated: Set the SchemaAdapterFactory for the crate::ListingTable
SchemaAdapterFactory has been removed. Use Self::with_expr_adapter_factory
and PhysicalExprAdapterFactory instead. See upgrading.md for more details.
This method is a no-op and returns self unchanged.
Trait Implementations§
Source§impl Clone for ListingTableConfig
impl Clone for ListingTableConfig
Source§fn clone(&self) -> ListingTableConfig
fn clone(&self) -> ListingTableConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ListingTableConfig
impl Debug for ListingTableConfig
Source§impl Default for ListingTableConfig
impl Default for ListingTableConfig
Source§fn default() -> ListingTableConfig
fn default() -> ListingTableConfig
Auto Trait Implementations§
impl Freeze for ListingTableConfig
impl !RefUnwindSafe for ListingTableConfig
impl Send for ListingTableConfig
impl Sync for ListingTableConfig
impl Unpin for ListingTableConfig
impl !UnwindSafe for ListingTableConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more