Skip to main content

GroupedData

Struct GroupedData 

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

Grouped data for performing aggregations.

Mirrors pyspark.sql.GroupedData.

Implementations§

Source§

impl GroupedData

Source

pub fn pivot( &self, pivot_col: Column, values: Option<Vec<Value>>, ) -> GroupedData

Pivot on a column, optionally with explicit values (GroupedData.pivot).

Mirrors df.groupBy(...).pivot(col, values). When values is None the server computes the distinct values; when supplied they are serialized as pivot-value literals (previously they were dropped entirely).

Source

pub fn input_columns(&self) -> Result<Vec<String>>

Column names of the underlying (pre-grouping) DataFrame. These are passed as the map/apply UDF’s argument columns so the worker’s pandas/Arrow input is named.

Source

pub fn apply_in_pandas( &self, func: CommonInlineUserDefinedFunctionExpression, ) -> DataFrame

Apply a pandas UDF to each group (GroupedData.applyInPandas).

func is built on the Python side (cloudpickled, eval type SQL_GROUPED_MAP_PANDAS_UDF).

Source

pub fn apply_in_arrow( &self, func: CommonInlineUserDefinedFunctionExpression, ) -> DataFrame

Apply an Arrow UDF to each group (GroupedData.applyInArrow).

Source

pub fn apply_in_pandas_with_state( &self, func: CommonInlineUserDefinedFunctionExpression, state_schema: DataType, output_mode: &str, timeout_conf: &str, ) -> DataFrame

Apply a stateful pandas UDF to each group (GroupedData.applyInPandasWithState).

func (built on the Python side with eval type SQL_GROUPED_MAP_PANDAS_UDF_WITH_STATE and carrying the output schema as its return type) is combined with the state schema, output mode, and timeout.

Source

pub fn transform_with_state( &self, func: CommonInlineUserDefinedFunctionExpression, output_mode: &str, time_mode: &str, event_time_column_name: Option<&str>, initial_state: Option<&GroupedData>, ) -> DataFrame

GroupedData.transformWithState (row output). func is the cloudpickled stateful processor (eval type in the 211-214 range).

Source

pub fn transform_with_state_in_pandas( &self, func: CommonInlineUserDefinedFunctionExpression, output_schema: DataType, output_mode: &str, time_mode: &str, event_time_column_name: Option<&str>, initial_state: Option<&GroupedData>, ) -> DataFrame

GroupedData.transformWithStateInPandas (carries the output schema in the TransformWithStateInfo).

Source

pub fn cogroup(&self, other: &GroupedData) -> CoGroupedData

Cogroup this grouped data with another (GroupedData.cogroup).

Source

pub fn agg(&self, expressions: Vec<Expression>) -> DataFrame

Perform an aggregation.

Source

pub fn count(&self) -> DataFrame

Count rows in each group.

Source

pub fn sum(&self, columns: Vec<&str>) -> DataFrame

Sum values in each group.

Source

pub fn avg(&self, columns: Vec<&str>) -> DataFrame

Average values in each group.

Source

pub fn min(&self, columns: Vec<&str>) -> DataFrame

Minimum values in each group.

Source

pub fn max(&self, columns: Vec<&str>) -> DataFrame

Maximum values in each group.

Source

pub fn mean(&self, columns: Vec<&str>) -> DataFrame

Mean (alias for avg).

Trait Implementations§

Source§

impl Clone for GroupedData

Source§

fn clone(&self) -> GroupedData

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

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> 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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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