Struct datafusion::datasource::file_format::options::CsvReadOptions
source · pub struct CsvReadOptions<'a> {
pub has_header: bool,
pub delimiter: u8,
pub quote: u8,
pub escape: Option<u8>,
pub schema: Option<&'a Schema>,
pub schema_infer_max_records: usize,
pub file_extension: &'a str,
pub table_partition_cols: Vec<(String, DataType)>,
pub file_compression_type: FileCompressionType,
pub file_sort_order: Vec<Vec<Expr>>,
}
Expand description
Options that control the reading of CSV files.
Note this structure is supplied when a datasource is created and
can not not vary from statement to statement. For settings that
can vary statement to statement see
ConfigOptions
.
Fields§
§has_header: bool
Does the CSV file have a header?
If schema inference is run on a file with no headers, default column names are created.
delimiter: u8
An optional column delimiter. Defaults to b','
.
quote: u8
An optional quote character. Defaults to b'"'
.
escape: Option<u8>
An optional escape character. Defaults to None.
schema: Option<&'a Schema>
An optional schema representing the CSV files. If None, CSV reader will try to infer it based on data in file.
schema_infer_max_records: usize
Max number of rows to read from CSV files for schema inference if needed. Defaults to DEFAULT_SCHEMA_INFER_MAX_RECORD
.
file_extension: &'a str
File extension; only files with this extension are selected for data input.
Defaults to FileType::CSV.get_ext().as_str()
.
table_partition_cols: Vec<(String, DataType)>
Partition Columns
file_compression_type: FileCompressionType
File compression type
file_sort_order: Vec<Vec<Expr>>
Indicates how the file is sorted
Implementations§
source§impl<'a> CsvReadOptions<'a>
impl<'a> CsvReadOptions<'a>
sourcepub fn has_header(self, has_header: bool) -> Self
pub fn has_header(self, has_header: bool) -> Self
Configure has_header setting
sourcepub fn file_extension(self, file_extension: &'a str) -> Self
pub fn file_extension(self, file_extension: &'a str) -> Self
Specify the file extension for CSV file selection
sourcepub fn delimiter_option(self, delimiter: Option<u8>) -> Self
pub fn delimiter_option(self, delimiter: Option<u8>) -> Self
Configure delimiter setting with Option, None value will be ignored
sourcepub fn table_partition_cols(
self,
table_partition_cols: Vec<(String, DataType)>
) -> Self
pub fn table_partition_cols( self, table_partition_cols: Vec<(String, DataType)> ) -> Self
Specify table_partition_cols for partition pruning
sourcepub fn schema_infer_max_records(self, max_records: usize) -> Self
pub fn schema_infer_max_records(self, max_records: usize) -> Self
Configure number of max records to read for schema inference
sourcepub fn file_compression_type(
self,
file_compression_type: FileCompressionType
) -> Self
pub fn file_compression_type( self, file_compression_type: FileCompressionType ) -> Self
Configure file compression type
sourcepub fn file_sort_order(self, file_sort_order: Vec<Vec<Expr>>) -> Self
pub fn file_sort_order(self, file_sort_order: Vec<Vec<Expr>>) -> Self
Configure if file has known sort order
Trait Implementations§
source§impl<'a> Clone for CsvReadOptions<'a>
impl<'a> Clone for CsvReadOptions<'a>
source§fn clone(&self) -> CsvReadOptions<'a>
fn clone(&self) -> CsvReadOptions<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a> Default for CsvReadOptions<'a>
impl<'a> Default for CsvReadOptions<'a>
source§impl ReadOptions<'_> for CsvReadOptions<'_>
impl ReadOptions<'_> for CsvReadOptions<'_>
source§fn to_listing_options(
&self,
config: &SessionConfig,
table_options: TableOptions
) -> ListingOptions
fn to_listing_options( &self, config: &SessionConfig, table_options: TableOptions ) -> ListingOptions
ListingTable
optionssource§fn get_resolved_schema<'life0, 'life1, 'async_trait>(
&'life0 self,
config: &'life1 SessionConfig,
state: SessionState,
table_path: ListingTableUrl
) -> Pin<Box<dyn Future<Output = Result<SchemaRef>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_resolved_schema<'life0, 'life1, 'async_trait>(
&'life0 self,
config: &'life1 SessionConfig,
state: SessionState,
table_path: ListingTableUrl
) -> Pin<Box<dyn Future<Output = Result<SchemaRef>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
source§fn _get_resolved_schema<'life0, 'async_trait>(
&'a self,
config: &'life0 SessionConfig,
state: SessionState,
table_path: ListingTableUrl,
schema: Option<&'a Schema>
) -> Pin<Box<dyn Future<Output = Result<SchemaRef>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn _get_resolved_schema<'life0, 'async_trait>(
&'a self,
config: &'life0 SessionConfig,
state: SessionState,
table_path: ListingTableUrl,
schema: Option<&'a Schema>
) -> Pin<Box<dyn Future<Output = Result<SchemaRef>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl<'a> Freeze for CsvReadOptions<'a>
impl<'a> !RefUnwindSafe for CsvReadOptions<'a>
impl<'a> Send for CsvReadOptions<'a>
impl<'a> Sync for CsvReadOptions<'a>
impl<'a> Unpin for CsvReadOptions<'a>
impl<'a> !UnwindSafe for CsvReadOptions<'a>
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> 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