pub struct DataEngine {
pub ctx: SessionContext,
pub rt: Arc<Runtime>,
}Expand description
Synchronous wrapper around DataFusion’s async SessionContext.
Fields§
§ctx: SessionContext§rt: Arc<Runtime>Implementations§
Source§impl DataEngine
impl DataEngine
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new DataEngine with default configuration. Backward-compatible with existing code.
Sourcepub fn with_config(config: DataEngineConfig) -> Self
pub fn with_config(config: DataEngineConfig) -> Self
Create a new DataEngine with custom configuration.
Sourcepub fn collect(&self, df: DataFrame) -> Result<Vec<RecordBatch>, String>
pub fn collect(&self, df: DataFrame) -> Result<Vec<RecordBatch>, String>
Execute a DataFusion DataFrame and collect results synchronously.
Sourcepub fn format_batches(batches: &[RecordBatch]) -> Result<String, String>
pub fn format_batches(batches: &[RecordBatch]) -> Result<String, String>
Format collected batches as a pretty table string.
Sourcepub fn register_batch(
&self,
name: &str,
batch: RecordBatch,
) -> Result<(), String>
pub fn register_batch( &self, name: &str, batch: RecordBatch, ) -> Result<(), String>
Register a RecordBatch as a named table in the session.
Sourcepub fn register_batches(
&self,
name: &str,
schema: Arc<Schema>,
batches: Vec<RecordBatch>,
) -> Result<(), String>
pub fn register_batches( &self, name: &str, schema: Arc<Schema>, batches: Vec<RecordBatch>, ) -> Result<(), String>
Register multiple RecordBatches as a single named table. Each batch becomes a separate partition, enabling DataFusion parallelism.
Sourcepub fn sql(&self, query: &str) -> Result<DataFrame, String>
pub fn sql(&self, query: &str) -> Result<DataFrame, String>
Run a SQL query and return results.
Sourcepub fn session_ctx(&self) -> &SessionContext
pub fn session_ctx(&self) -> &SessionContext
Get the underlying session context for DataFusion operations.
Source§impl DataEngine
impl DataEngine
Sourcepub fn read_csv(&self, path: &str) -> Result<DataFrame, String>
pub fn read_csv(&self, path: &str) -> Result<DataFrame, String>
Read a CSV file into a DataFusion DataFrame. Supports local paths and s3:// URLs (after register_s3).
Sourcepub fn read_parquet(&self, path: &str) -> Result<DataFrame, String>
pub fn read_parquet(&self, path: &str) -> Result<DataFrame, String>
Read a Parquet file into a DataFusion DataFrame. Supports local paths and s3:// URLs (after register_s3).
Source§impl DataEngine
impl DataEngine
Sourcepub fn read_postgres(
&self,
conn_str: &str,
table_name: &str,
) -> Result<DataFrame, String>
pub fn read_postgres( &self, conn_str: &str, table_name: &str, ) -> Result<DataFrame, String>
Read a PostgreSQL table into a DataFusion DataFrame.
Sourcepub fn query_postgres(
&self,
conn_str: &str,
query: &str,
register_as: &str,
) -> Result<DataFrame, String>
pub fn query_postgres( &self, conn_str: &str, query: &str, register_as: &str, ) -> Result<DataFrame, String>
Execute a custom SQL query against PostgreSQL and return a DataFusion DataFrame. Fetches 1M rows per cursor round trip, then subdivides into 100K-row RecordBatches for DataFusion parallelism. Falls back to a simple query if cursors are not supported (e.g., PgBouncer, some cloud proxies, or restricted permissions).
Source§impl DataEngine
impl DataEngine
Sourcepub fn fill_null(
&self,
df: DataFrame,
column: &str,
strategy: &str,
fill_value: Option<f64>,
) -> Result<DataFrame, String>
pub fn fill_null( &self, df: DataFrame, column: &str, strategy: &str, fill_value: Option<f64>, ) -> Result<DataFrame, String>
Fill null values in a column using a strategy. strategy: “value” (use fill_value), “mean”, “zero”
Sourcepub fn drop_null(
&self,
df: DataFrame,
column: &str,
) -> Result<DataFrame, String>
pub fn drop_null( &self, df: DataFrame, column: &str, ) -> Result<DataFrame, String>
Drop rows where a column is null.
Sourcepub fn dedup(
&self,
df: DataFrame,
columns: &[String],
) -> Result<DataFrame, String>
pub fn dedup( &self, df: DataFrame, columns: &[String], ) -> Result<DataFrame, String>
Remove duplicate rows based on specified columns.
Sourcepub fn clamp(
&self,
df: DataFrame,
column: &str,
min_val: f64,
max_val: f64,
) -> Result<DataFrame, String>
pub fn clamp( &self, df: DataFrame, column: &str, min_val: f64, max_val: f64, ) -> Result<DataFrame, String>
Clamp values in a column to [min_val, max_val].
Sourcepub fn data_profile(&self, df: DataFrame) -> Result<DataFrame, String>
pub fn data_profile(&self, df: DataFrame) -> Result<DataFrame, String>
Generate a statistical profile of all numeric columns. Returns a table with: column_name, count, null_count, null_rate, min, max, mean, stddev
Sourcepub fn row_count(&self, df: DataFrame) -> Result<i64, String>
pub fn row_count(&self, df: DataFrame) -> Result<i64, String>
Get the row count of a DataFrame.
Source§impl DataEngine
impl DataEngine
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DataEngine
impl !RefUnwindSafe for DataEngine
impl Send for DataEngine
impl Sync for DataEngine
impl Unpin for DataEngine
impl UnsafeUnpin for DataEngine
impl !UnwindSafe for DataEngine
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 moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);