pub struct CustomDataFrame {
pub df: DataFrame,
pub table_alias: String,
/* private fields */
}Expand description
Helper function to extract partition values from a RecordBatch based on partition columns. Assumes that each RecordBatch has a single unique partition value.
Fields§
§df: DataFrame§table_alias: StringImplementations§
Source§impl CustomDataFrame
impl CustomDataFrame
Sourcepub async fn new<'a>(
file_path: &'a str,
columns: Vec<(&'a str, &'a str, bool)>,
alias: &'a str,
) -> Self
pub async fn new<'a>( file_path: &'a str, columns: Vec<(&'a str, &'a str, bool)>, alias: &'a str, ) -> Self
NEW method for loading and schema definition
Sourcepub async fn raw_sql(
&self,
sql: &str,
alias: &str,
dfs: &[&CustomDataFrame],
) -> ElusionResult<Self>
pub async fn raw_sql( &self, sql: &str, alias: &str, dfs: &[&CustomDataFrame], ) -> ElusionResult<Self>
Execute a raw SQL query involving multiple CustomDataFrame instances and return a new CustomDataFrame with the results.
§Arguments
sql- The raw SQL query string to execute.alias- The alias name for the resulting DataFrame.additional_dfs- A slice of references to other CustomDataFrame instances to be registered in the context.
§Returns
ElusionResult<Self>- A newCustomDataFramecontaining the result of the SQL query.
Sourcepub fn load_csv<'a>(
file_path: &'a str,
schema: Arc<Schema>,
alias: &'a str,
) -> BoxFuture<'a, Result<AliasedDataFrame, DataFusionError>>
pub fn load_csv<'a>( file_path: &'a str, schema: Arc<Schema>, alias: &'a str, ) -> BoxFuture<'a, Result<AliasedDataFrame, DataFusionError>>
LOAD function for CSV file type
Sourcepub fn load_json<'a>(
file_path: &'a str,
alias: &'a str,
) -> BoxFuture<'a, Result<AliasedDataFrame, DataFusionError>>
pub fn load_json<'a>( file_path: &'a str, alias: &'a str, ) -> BoxFuture<'a, Result<AliasedDataFrame, DataFusionError>>
Sourcepub fn load<'a>(
file_path: &'a str,
schema: Arc<Schema>,
alias: &'a str,
) -> BoxFuture<'a, Result<AliasedDataFrame, DataFusionError>>
pub fn load<'a>( file_path: &'a str, schema: Arc<Schema>, alias: &'a str, ) -> BoxFuture<'a, Result<AliasedDataFrame, DataFusionError>>
unified load() funciton
Sourcepub fn aggregation(self, aggregations: Vec<AggregationBuilder>) -> Self
pub fn aggregation(self, aggregations: Vec<AggregationBuilder>) -> Self
AGGREAGATION helper
Sourcepub fn from_subquery(self, sub_df: CustomDataFrame, alias: &str) -> Self
pub fn from_subquery(self, sub_df: CustomDataFrame, alias: &str) -> Self
FROM SUBQUERY clause
Sourcepub fn with_cte(self, name: &str, cte_df: CustomDataFrame) -> Self
pub fn with_cte(self, name: &str, cte_df: CustomDataFrame) -> Self
WITH CTE claUse
Sourcepub fn union(self, other: CustomDataFrame, all: bool) -> Self
pub fn union(self, other: CustomDataFrame, all: bool) -> Self
UNION clause
Sourcepub fn intersect(self, other: CustomDataFrame, all: bool) -> Self
pub fn intersect(self, other: CustomDataFrame, all: bool) -> Self
INTERSECT cluase
Sourcepub fn except(self, other: CustomDataFrame, all: bool) -> Self
pub fn except(self, other: CustomDataFrame, all: bool) -> Self
EXCEPT clause
Sourcepub fn filter(self, condition: &str) -> Self
pub fn filter(self, condition: &str) -> Self
FILTER clause Applies a WHERE filter with automatic lowercasing
Sourcepub fn having(self, condition: &str) -> Self
pub fn having(self, condition: &str) -> Self
Applies a HAVING filter with automatic lowercasing
Sourcepub fn join(
self,
other: CustomDataFrame,
condition: &str,
join_type: &str,
) -> Self
pub fn join( self, other: CustomDataFrame, condition: &str, join_type: &str, ) -> Self
JOIN clause
Sourcepub fn window(
self,
func: &str,
column: &str,
partition_by: Vec<&str>,
order_by: Vec<&str>,
alias: Option<&str>,
) -> Self
pub fn window( self, func: &str, column: &str, partition_by: Vec<&str>, order_by: Vec<&str>, alias: Option<&str>, ) -> Self
WINDOW CLAUSE
Sourcepub fn add_column_with_cast(
self,
column: &str,
new_alias: &str,
data_type: &str,
) -> Self
pub fn add_column_with_cast( self, column: &str, new_alias: &str, data_type: &str, ) -> Self
CAST function
Sourcepub fn add_column_with_trim(self, column: &str, new_alias: &str) -> Self
pub fn add_column_with_trim(self, column: &str, new_alias: &str) -> Self
TRIM funciton
Sourcepub fn add_column_with_regex(
self,
column: &str,
pattern: &str,
new_alias: &str,
) -> Self
pub fn add_column_with_regex( self, column: &str, pattern: &str, new_alias: &str, ) -> Self
REGEX function
Sourcepub fn display_query_plan(&self)
pub fn display_query_plan(&self)
DISPLAY Query Plan
Sourcepub fn display_schema(&self)
pub fn display_schema(&self)
Displays the current schema for debugging purposes.
Sourcepub fn display_query(&self)
pub fn display_query(&self)
Dipslaying query genereated from chained functions
Sourcepub async fn display(&self) -> Result<(), DataFusionError>
pub async fn display(&self) -> Result<(), DataFusionError>
Display functions that display results to terminal
Sourcepub async fn write_to_parquet(
&self,
mode: &str,
path: &str,
options: Option<DataFrameWriteOptions>,
) -> ElusionResult<()>
pub async fn write_to_parquet( &self, mode: &str, path: &str, options: Option<DataFrameWriteOptions>, ) -> ElusionResult<()>
Write the DataFrame to a Parquet file.
This function wraps DataFusion’s write_parquet method for easier usage.
§Parameters
mode: Specifies the write mode. Accepted values are:"overwrite": Deletes existing files at the target path before writing."append": Appends to the existing Parquet file if it exists.
path: The file path where the Parquet file will be saved.options: Optional write options for customizing the output.
§Example
// Write to Parquet in overwrite mode
custom_df.write_to_parquet("overwrite", "output.parquet", None).await?;
// Write to Parquet in append mode
custom_df.write_to_parquet("append", "output.parquet", None).await?;§Errors
Returns a DataFusionError if the DataFrame execution or writing fails.
Sourcepub async fn write_to_csv(
&self,
mode: &str,
path: &str,
csv_options: CsvWriteOptions,
) -> ElusionResult<()>
pub async fn write_to_csv( &self, mode: &str, path: &str, csv_options: CsvWriteOptions, ) -> ElusionResult<()>
Writes the DataFrame to a CSV file in either “overwrite” or “append” mode.
§Arguments
mode- The write mode, either “overwrite” or “append”.path- The file path where the CSV will be written.options- OptionalDataFrameWriteOptionsfor customizing the write behavior.
§Returns
ElusionResult<()>- Ok(()) on success, or anElusionErroron failure.
Trait Implementations§
Source§impl Clone for CustomDataFrame
impl Clone for CustomDataFrame
Source§fn clone(&self) -> CustomDataFrame
fn clone(&self) -> CustomDataFrame
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CustomDataFrame
impl !RefUnwindSafe for CustomDataFrame
impl Send for CustomDataFrame
impl Sync for CustomDataFrame
impl Unpin for CustomDataFrame
impl !UnwindSafe for CustomDataFrame
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