ListingTableConfig

Struct ListingTableConfig 

Source
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 0 or "".

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

Source

pub fn new(table_path: ListingTableUrl) -> Self

Creates new ListingTableConfig for reading the specified URL

Source

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

Source

pub fn schema_source(&self) -> SchemaSource

Returns the source of the schema for this configuration

Source

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 schema
Source

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 options
Source

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)

Source

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
Source

pub async fn infer_partitions_from_path( self, state: &dyn Session, ) -> Result<Self>

Infer the partition columns from table_paths.

§Errors
Source

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.

Source

pub 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.

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

Source§

fn clone(&self) -> ListingTableConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ListingTableConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ListingTableConfig

Source§

fn default() -> ListingTableConfig

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,