Skip to main content

SqlDataFrame

Struct SqlDataFrame 

Source
pub struct SqlDataFrame { /* private fields */ }
Expand description

Krishiv-owned wrapper around a DataFusion DataFrame.

Implementations§

Source§

impl SqlDataFrame

Source

pub fn query(&self) -> Option<&str>

Original SQL query when created from SqlEngine::sql.

Source

pub fn krishiv_logical_plan(&self) -> LogicalPlan

Create a Krishiv logical plan wrapper for this DataFrame.

Walks the DataFusion logical plan tree, creating Krishiv PlanNode entries for each operator. Table-scan nodes are annotated with estimated_rows from the engine’s table-row-count registry, allowing BroadcastAutoRule to identify small tables for broadcast join promotion. The plan is then run through the logical optimizer before being returned.

Source

pub fn explain_logical(&self) -> String

Explain the logical plan without executing it.

Source

pub async fn explain(&self) -> SqlResult<String>

Explain logical and physical plan details through DataFusion.

Source

pub async fn collect(&self) -> SqlResult<Vec<RecordBatch>>

Execute and collect this DataFrame.

Source

pub async fn execute_stream(&self) -> SqlResult<SqlStream>

Execute and return a record batch stream.

Source

pub async fn collect_with_stats( &self, ) -> SqlResult<(Vec<RecordBatch>, SqlExecutionStats)>

Execute and collect this DataFrame, also returning lightweight runtime statistics.

Collects output_rows from DataFusion’s execution metrics. cpu_nanos is approximated from elapsed_compute when available. spill_bytes and spill_count are aggregated across every operator in the physical plan tree (sorts, hash joins, and aggregations report spills when the memory pool forces them to disk); other fields default to 0.

Trait Implementations§

Source§

impl Clone for SqlDataFrame

Source§

fn clone(&self) -> SqlDataFrame

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SqlDataFrame

Source§

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

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

impl KrishivDataFrameOps for SqlDataFrame

Source§

fn collect<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = SqlResult<Vec<RecordBatch>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute and collect all result batches.
Source§

fn collect_with_stats<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = SqlResult<(Vec<RecordBatch>, SqlExecutionStats)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute, collect results, and return lightweight runtime statistics.
Source§

fn explain<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = SqlResult<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Explain the physical and logical plan text (does not execute).
Source§

fn explain_logical(&self) -> String

Explain the logical plan text without executing.
Source§

fn krishiv_logical_plan(&self) -> LogicalPlan

Build a Krishiv LogicalPlan wrapper for this DataFrame.
Source§

fn query(&self) -> Option<&str>

The original SQL query string, if any.
Source§

fn execute_stream<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = SqlResult<SqlStream>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute and return a record batch stream.
Source§

fn schema(&self) -> SchemaRef

Return the Arrow schema of this DataFrame.
Source§

fn select<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, columns: &'life1 [&'life2 str], ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Select columns by name.
Source§

fn select_exprs<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, expressions: &'life1 [&'life2 Expr], ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Select arbitrary SQL expressions.
Source§

fn aggregate<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, group_exprs: &'life1 [&'life2 Expr], aggregate_exprs: &'life3 [&'life4 Expr], ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Group by expressions and compute aggregate expressions.
Source§

fn aggregate_grouping<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, grouping: GroupingMode<'life1>, aggregate_exprs: &'life2 [&'life3 Expr], ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Aggregate using GROUPING SETS, CUBE, or ROLLUP.
Source§

fn pivot<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, group_exprs: &'life1 [&'life2 Expr], pivot_column: &'life3 Expr, aggregate_expr: &'life4 Expr, values: &'life5 [(ScalarValue, String)], ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait,

Pivot known values into aggregate columns.
Source§

fn unpivot<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, columns: &'life1 [&'life2 str], name_column: &'life3 str, value_column: &'life4 str, ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Unpivot columns into name/value rows while preserving other columns.
Source§

fn filter<'life0, 'life1, 'async_trait>( &'life0 self, predicate: &'life1 str, ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Filter rows by a SQL predicate expression.
Source§

fn filter_expr<'life0, 'life1, 'async_trait>( &'life0 self, predicate: &'life1 Expr, ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Filter rows using the engine-owned typed expression AST.
Source§

fn limit<'life0, 'async_trait>( &'life0 self, n: usize, ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Limit the number of rows.
Source§

fn distinct<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remove duplicate rows.
Source§

fn drop_nulls<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, columns: &'life1 [&'life2 str], ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Drop rows with nulls in selected columns; an empty list checks all columns.
Source§

fn sample<'life0, 'async_trait>( &'life0 self, fraction: f64, ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Bernoulli-sample rows.
Source§

fn sort<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, columns: &'life1 [&'life2 str], descending: &'life3 [bool], ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Sort by columns with optional descending flags.
Source§

fn alias<'life0, 'life1, 'async_trait>( &'life0 self, alias: &'life1 str, ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Assign an alias (table name) to this DataFrame.
Source§

fn drop_columns<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, columns: &'life1 [&'life2 str], ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Drop columns by name.
Source§

fn rename_column<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, old: &'life1 str, new: &'life2 str, ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Rename a column from old to new.
Source§

fn with_column<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, name: &'life1 str, expr: &'life2 str, ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Add or replace a column with a computed expression.
Source§

fn as_any(&self) -> &dyn Any

Return the underlying concrete type for downcasting.
Source§

fn describe<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Compute summary statistics (delegates to DataFusion’s describe).
Source§

fn fill_null<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, column: &'life1 str, value: &'life2 str, ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Fill null values in column with the literal SQL value.
Source§

fn join<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'life6, 'async_trait>( &'life0 self, right: &'life1 dyn KrishivDataFrameOps, how: &'life2 str, left_on: &'life3 [&'life4 str], right_on: &'life5 [&'life6 str], ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait, 'life6: 'async_trait,

Join with another DataFrame using a join type and equi-join keys.
Source§

fn union<'life0, 'life1, 'async_trait>( &'life0 self, right: &'life1 dyn KrishivDataFrameOps, ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Union this DataFrame with another (UNION ALL semantics).
Source§

fn union_distinct<'life0, 'life1, 'async_trait>( &'life0 self, right: &'life1 dyn KrishivDataFrameOps, ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn intersect<'life0, 'life1, 'async_trait>( &'life0 self, right: &'life1 dyn KrishivDataFrameOps, distinct: bool, ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn except<'life0, 'life1, 'async_trait>( &'life0 self, right: &'life1 dyn KrishivDataFrameOps, distinct: bool, ) -> Pin<Box<dyn Future<Output = SqlResult<Box<dyn KrishivDataFrameOps>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn register_batches<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, batches: Vec<RecordBatch>, ) -> Pin<Box<dyn Future<Output = SqlResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Register a list of record batches as a named in-memory table in the same session context that backs this DataFrame. Used by cache().
Source§

fn deregister_table<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, ) -> Pin<Box<dyn Future<Output = SqlResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Deregister a named table from the session context. Used by unpersist().
Source§

fn create_view<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, replace: bool, ) -> Pin<Box<dyn Future<Output = SqlResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create (or replace) a SQL view named name backed by this DataFrame’s query. Used by create_or_replace_temp_view().

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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: Sized + 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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