DataFilter

Struct DataFilter 

Source
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: PathBuf

The canonical, absolute path to the data file.

§table_name: String

The name assigned to the loaded DataFrame for use in SQL queries.

§csv_delimiter: String

The character used to separate columns in a CSV file.

§read_data_from_file: bool

Read 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: usize

Maximum rows to scan for schema inference (CSV, JSON, NDJson).

§exclude_null_cols: bool

Flag to control removal of all-null columns after loading/querying.

§null_values: String

Comma-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: bool

Flag 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: String

The SQL query string entered by the user.

§add_row_index: bool

Flag indicating if a row index column should be added.

§index_column_name: String

The desired name for the row index column (will be checked for uniqueness later).

§index_column_offset: u32

The starting value for the row index column (e.g., 0 or 1).

§normalize: bool

Flag indicating whether string columns will be normalized.

§normalize_regex: String

Regex pattern to select string columns.

§drop: bool§drop_regex: String

Implementations§

Source§

impl DataFilter

Source

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

Source

pub fn set_path(&mut self, path: &Path) -> PolarsViewResult<()>

Sets the data source path, canonicalizing it.

Source

pub fn get_extension(&self) -> Option<String>

Gets the file extension from absolute_path in lowercase.

Source

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.

Source

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.

Source

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:

  1. Splits the input string (self.null_values) by commas.
  2. Iterates through each resulting substring (s).
  3. For each substring: a. Trims leading and trailing whitespace. b. Checks if the trimmed string 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 the trimmed string itself. Example: <N/D> remains <N/D>, NA becomes NA.
  4. Collects all the resulting string slices into a Vec<&str>.

Example Input: "\"\", \" \", <N/D>, NA " Example Output: vec!["", " ", "<N/D>", "NA"]

Source

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 asynchronous DataFrameContainer::load_data call.
  • 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: The egui::Ui context 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

Source§

fn clone(&self) -> DataFilter

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 DataFilter

Source§

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

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

impl Default for DataFilter

Source§

fn default() -> Self

Creates default DataFilter with sensible initial values.

Source§

impl PartialEq for DataFilter

Source§

fn eq(&self, other: &DataFilter) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for DataFilter

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Key for T
where T: Clone,

Source§

fn align() -> usize

The alignment necessary for the key. Must return a power of two.
Source§

fn size(&self) -> usize

The size of the key in bytes.
Source§

unsafe fn init(&self, ptr: *mut u8)

Initialize the key in the given memory location. Read more
Source§

unsafe fn get<'a>(ptr: *const u8) -> &'a T

Get a reference to the key from the given memory location. Read more
Source§

unsafe fn drop_in_place(ptr: *mut u8)

Drop the key in place. Read more
Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> PlanCallbackArgs for T

Source§

impl<T> PlanCallbackOut for T