pub struct DataFrameWriter { /* private fields */ }
Expand description
DataFrameWriter provides the ability to output a DataFrame to a specific file format supported by Spark
Implementations§
Source§impl DataFrameWriter
impl DataFrameWriter
Sourcepub fn new(dataframe: DataFrame) -> Self
pub fn new(dataframe: DataFrame) -> Self
Create a new DataFrameWriter from a provided DataFrame
§Defaults
format
: None,mode
: SaveMode::Overwrite,bucket_by
: None,partition_by
: vec![],sort_by
: vec![],write_options
: HashMap::new()
Sourcepub fn bucket_by<'a, I>(self, num_buckets: i32, buckets: I) -> Selfwhere
I: IntoIterator<Item = &'a str>,
pub fn bucket_by<'a, I>(self, num_buckets: i32, buckets: I) -> Selfwhere
I: IntoIterator<Item = &'a str>,
Buckets the output by the given columns. If specified, the output is laid out on the file system similar to Hive’s bucketing scheme.
Sourcepub fn sort_by<'a, I>(self, cols: I) -> Selfwhere
I: IntoIterator<Item = &'a str>,
pub fn sort_by<'a, I>(self, cols: I) -> Selfwhere
I: IntoIterator<Item = &'a str>,
Sorts the output in each bucket by the given columns on the file system
Sourcepub fn partition_by<'a, I>(self, cols: I) -> Selfwhere
I: IntoIterator<Item = &'a str>,
pub fn partition_by<'a, I>(self, cols: I) -> Selfwhere
I: IntoIterator<Item = &'a str>,
Partitions the output by the given columns on the file system
Sourcepub fn option(self, key: &str, value: &str) -> Self
pub fn option(self, key: &str, value: &str) -> Self
Add an input option for the underlying data source
Sourcepub fn options<I, K, V>(self, options: I) -> Self
pub fn options<I, K, V>(self, options: I) -> Self
Set many input options based on an iterator of (key/value pairs) for the underlying data source
Sourcepub async fn save(self, path: &str) -> Result<(), SparkError>
pub async fn save(self, path: &str) -> Result<(), SparkError>
Save the contents of the DataFrame to a data source.
The data source is specified by the format
and a set of options
.
Sourcepub async fn save_as_table(self, table_name: &str) -> Result<(), SparkError>
pub async fn save_as_table(self, table_name: &str) -> Result<(), SparkError>
Saves the context of the DataFrame as the specified table.
Sourcepub async fn insert_into(self, table_name: &str) -> Result<(), SparkError>
pub async fn insert_into(self, table_name: &str) -> Result<(), SparkError>
Sourcepub async fn csv<C: ConfigOpts>(
self,
path: &str,
config: C,
) -> Result<(), SparkError>
pub async fn csv<C: ConfigOpts>( self, path: &str, config: C, ) -> Result<(), SparkError>
Writes the DataFrame to a CSV file with the specified options.
Sourcepub async fn json<C: ConfigOpts>(
self,
path: &str,
config: C,
) -> Result<(), SparkError>
pub async fn json<C: ConfigOpts>( self, path: &str, config: C, ) -> Result<(), SparkError>
Writes the DataFrame to a JSON file with the specified options.
Sourcepub async fn orc<C: ConfigOpts>(
self,
path: &str,
config: C,
) -> Result<(), SparkError>
pub async fn orc<C: ConfigOpts>( self, path: &str, config: C, ) -> Result<(), SparkError>
Writes the DataFrame to an ORC file with the specified options.
Sourcepub async fn parquet<C: ConfigOpts>(
self,
path: &str,
config: C,
) -> Result<(), SparkError>
pub async fn parquet<C: ConfigOpts>( self, path: &str, config: C, ) -> Result<(), SparkError>
Writes the DataFrame to a Parquet file with the specified options.
Sourcepub async fn text<C: ConfigOpts>(
self,
path: &str,
config: C,
) -> Result<(), SparkError>
pub async fn text<C: ConfigOpts>( self, path: &str, config: C, ) -> Result<(), SparkError>
Writes the DataFrame to a text file with the specified options.
Auto Trait Implementations§
impl Freeze for DataFrameWriter
impl !RefUnwindSafe for DataFrameWriter
impl Send for DataFrameWriter
impl Sync for DataFrameWriter
impl Unpin for DataFrameWriter
impl !UnwindSafe for DataFrameWriter
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request