pub struct DataFilter {Show 18 fields
pub absolute_path: PathBuf,
pub table_name: String,
pub csv_delimiter: String,
pub read_data_from_file: bool,
pub schema: Arc<Schema>,
pub infer_schema_rows: usize,
pub exclude_null_cols: bool,
pub null_values: String,
pub force_string_patterns: Option<String>,
pub apply_sql: bool,
pub query: String,
pub add_row_index: bool,
pub index_column_name: String,
pub index_column_offset: u32,
pub normalize: bool,
pub normalize_regex: String,
pub drop: bool,
pub drop_regex: String,
}Expand description
Holds configuration parameters related to loading and querying data.
This struct focuses on settings that define how data is initially read from a file and transformed via SQL queries or basic processing like null column removal.
Instances are created from Arguments, updated by the UI in render_query, and passed
to DataFrameContainer::load_data. Changes here typically trigger a data reload/requery.
Fields§
§absolute_path: PathBufThe canonical, absolute path to the data file.
table_name: StringThe name assigned to the loaded DataFrame for use in SQL queries.
csv_delimiter: StringThe character used to separate columns in a CSV file.
read_data_from_file: boolRead data from file
schema: Arc<Schema>The schema (column names and data types) of the most recently loaded DataFrame.
Used by sql_commands for generating relevant examples.
infer_schema_rows: usizeMaximum rows to scan for schema inference (CSV, JSON, NDJson).
exclude_null_cols: boolFlag to control removal of all-null columns after loading/querying.
null_values: StringComma-separated string of values to interpret as nulls during CSV parsing.
force_string_patterns: Option<String>Regex patterns matching columns to force read as String type.
List of column names to force reading as String, overriding inference. Useful for columns with large IDs/keys that look numeric.
apply_sql: boolFlag indicating if the query should be executed during the next load_data.
Set by render_query if relevant UI fields change or the Apply button is clicked.
query: StringThe SQL query string entered by the user.
add_row_index: boolFlag indicating if a row index column should be added.
index_column_name: StringThe desired name for the row index column (will be checked for uniqueness later).
index_column_offset: u32The starting value for the row index column (e.g., 0 or 1).
normalize: boolFlag indicating whether string columns will be normalized.
normalize_regex: StringRegex pattern to select string columns.
drop: bool§drop_regex: StringImplementations§
Source§impl DataFilter
impl DataFilter
Sourcepub fn new(args: &Arguments) -> PolarsViewResult<Self>
pub fn new(args: &Arguments) -> PolarsViewResult<Self>
Creates a new DataFilter instance configured from command-line Arguments.
This is typically called once at application startup in main.rs.
§Arguments
args: Parsed command-line arguments (crate::Arguments).
§Returns
A PolarsViewResult containing the configured DataFilter or an error
(e.g., if the path cannot be canonicalized).
Sourcepub fn set_path(&mut self, path: &Path) -> PolarsViewResult<()>
pub fn set_path(&mut self, path: &Path) -> PolarsViewResult<()>
Sets the data source path, canonicalizing it.
Sourcepub fn get_extension(&self) -> Option<String>
pub fn get_extension(&self) -> Option<String>
Gets the file extension from absolute_path in lowercase.
Sourcepub fn get_row_index(&self, schema: &Schema) -> PolarsResult<Option<RowIndex>>
pub fn get_row_index(&self, schema: &Schema) -> PolarsResult<Option<RowIndex>>
Determines the configuration for an optional row index column by resolving a unique name against the provided schema.
If self.add_row_index is true, this method finds a unique name based on
self.index_column_name and the provided schema, returning a Some(RowIndex).
If the name resolution fails, it returns the specific PolarsError.
If self.add_row_index is false, it returns Ok(None).
§Arguments
schema: The schema against which the index column name should be checked for uniqueness. This should be the schema of the DataFrame before adding the index column.
§Returns
PolarsResult<Option<RowIndex>>: Ok(Some) if config is resolved, Ok(None) if disabled, Err if resolution fails.
Sourcepub async fn get_df_and_extension(
&mut self,
) -> PolarsViewResult<(DataFrame, FileExtension)>
pub async fn get_df_and_extension( &mut self, ) -> PolarsViewResult<(DataFrame, FileExtension)>
Determines the FileExtension and orchestrates loading the DataFrame using the appropriate Polars reader.
This method centralizes the file-type-specific loading logic. Called by DataFrameContainer::load_data.
Important: It mutates self by potentially updating csv_delimiter if automatic
detection during read_csv_data finds a different working delimiter than initially configured.
§Returns
A PolarsViewResult containing a tuple: (DataFrame, FileExtension) on success,
or a PolarsViewError (e.g., FileType, CsvParsing) on failure.
Sourcepub fn parse_null_values(&self) -> Vec<&str>
pub fn parse_null_values(&self) -> Vec<&str>
Parses the comma-separated null_values string into a Vec<&str>,
removing surrounding double quotes if present.
Logic:
- Splits the input string (
self.null_values) by commas. - Iterates through each resulting substring (
s). - For each substring:
a. Trims leading and trailing whitespace.
b. Checks if the
trimmedstring has at least 2 characters AND starts with"AND ends with". c. If true, returns a slice (&str) representing the content between the quotes. Example:"\"\""becomes""," N/A "becomes"N/A"," " "becomes" ". d. If false (no surrounding quotes), returns a slice (&str) of thetrimmedstring itself. Example:<N/D>remains<N/D>,NAbecomesNA. - Collects all the resulting string slices into a
Vec<&str>.
Example Input: "\"\", \" \", <N/D>, NA "
Example Output: vec!["", " ", "<N/D>", "NA"]
Sourcepub fn render_query(&mut self, ui: &mut Ui) -> Option<DataFilter>
pub fn render_query(&mut self, ui: &mut Ui) -> Option<DataFilter>
Renders the UI widgets for configuring data filters within the “Query” collapsing header.
This function is called by layout.rs::render_side_panel.
Crucially, it takes &mut self. Widgets modify self directly.
It compares the state of self before and after rendering the widgets.
If any change occurred (user typed in a field, clicked a checkbox), it returns
Some(self.clone()) containing the modified state. Otherwise, it returns None.
The layout.rs code uses this return value:
- If
Some(new_filters), it triggers an asynchronousDataFrameContainer::load_datacall. - If
None, no user change was detected in this frame, so no action is taken.
It also sets self.apply_sql = true if any changes are detected, ensuring the SQL
query is re-applied upon reload.
§Arguments
ui: Theegui::Uicontext for drawing the widgets.
§Returns
Some(DataFilter): If any filter setting was changed by the user in this frame.None: If no changes were detected.
Trait Implementations§
Source§impl Clone for DataFilter
impl Clone for DataFilter
Source§fn clone(&self) -> DataFilter
fn clone(&self) -> DataFilter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DataFilter
impl Debug for DataFilter
Source§impl Default for DataFilter
impl Default for DataFilter
Source§impl PartialEq for DataFilter
impl PartialEq for DataFilter
impl StructuralPartialEq for DataFilter
Auto Trait Implementations§
impl Freeze for DataFilter
impl RefUnwindSafe for DataFilter
impl Send for DataFilter
impl Sync for DataFilter
impl Unpin for DataFilter
impl UnwindSafe for DataFilter
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for 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> 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