Skip to main content

TableValuedFunction

Struct TableValuedFunction 

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

Table-valued functions for Spark SQL.

Mirrors pyspark.sql.connect.tvf.TableValuedFunction.

Implementations§

Source§

impl TableValuedFunction

Source

pub fn udtf( &self, name: &str, arguments: Vec<Column>, return_type: Option<DataType>, eval_type: i32, command: Vec<u8>, python_ver: String, deterministic: bool, ) -> DataFrame

Invoke a Python user-defined table function (UDTF), returning its output as a DataFrame. Mirrors pyspark.sql.functions.udtf. The Python side cloudpickles the handler and sets eval_type (300 SQL_TABLE_UDF, 301 SQL_ARROW_TABLE_UDF, 302 SQL_ARROW_UDTF); command is the pickled payload.

Source

pub fn range( &self, start: i64, end: Option<i64>, step: i64, num_partitions: Option<i32>, ) -> Result<DataFrame>

Create a DataFrame representing a range of integers.

This is a table-valued function that generates a sequence of integers from start to end with the given step.

§Arguments
  • start - Starting value (inclusive)
  • end - Ending value (exclusive) or the only value if called with one argument
  • step - Step size between values (default 1)
  • num_partitions - Number of partitions (optional)
§Example
let df = spark.tvf().range(0, 100, 1, None)?;
Source

pub fn explode(&self, collection: &Column) -> Result<DataFrame>

Explode an array or map column.

Returns a DataFrame where each array/map element becomes a separate row.

§Arguments
  • collection - The column to explode (must be an array or map)
§Example
let df = spark.tvf().explode(col("my_array"))?;
Source

pub fn explode_outer(&self, collection: &Column) -> Result<DataFrame>

Explode an array or map column, preserving nulls as empty rows.

Similar to explode, but null values are preserved.

Source

pub fn inline(&self, input: &Column) -> Result<DataFrame>

Inline an array of structs column.

Each struct becomes a separate row with its fields as columns.

§Arguments
  • input - The column to inline (must be an array of structs)
§Example
let df = spark.tvf().inline(col("struct_array"))?;
Source

pub fn inline_outer(&self, input: &Column) -> Result<DataFrame>

Inline an array of structs column, preserving nulls as empty rows.

Similar to inline, but null values are preserved.

Source

pub fn json_tuple<C: Into<Column>>( &self, input: &Column, fields: impl IntoIterator<Item = C>, ) -> Result<DataFrame>

JSON tuple function.

Extracts fields from a JSON string.

§Arguments
  • input - The JSON column
  • fields - Field names to extract
§Example
let df = spark.tvf().json_tuple(col("json_str"), vec![col("field1"), col("field2")])?;
Source

pub fn posexplode(&self, collection: &Column) -> Result<DataFrame>

Explode an array column with position indices.

Similar to explode, but also includes the position of each element.

Source

pub fn posexplode_outer(&self, collection: &Column) -> Result<DataFrame>

Explode an array column with position indices, preserving nulls.

Similar to posexplode, but null values are preserved.

Source

pub fn stack<C: Into<Column>>( &self, n: &Column, fields: impl IntoIterator<Item = C>, ) -> Result<DataFrame>

Stack function.

Converts multiple columns into rows.

§Arguments
  • n - The number of columns to stack
  • fields - The columns to stack
Source

pub fn collations(&self) -> Result<DataFrame>

Returns a DataFrame of collation names.

Source

pub fn sql_keywords(&self) -> Result<DataFrame>

Returns a DataFrame of SQL keywords.

Source

pub fn variant_explode(&self, input: &Column) -> Result<DataFrame>

Explode a variant column.

Variant columns contain semi-structured data in Spark SQL.

Source

pub fn variant_explode_outer(&self, input: &Column) -> Result<DataFrame>

Explode a variant column, preserving nulls.

Source

pub fn python_worker_logs(&self) -> Result<DataFrame>

Get Python worker logs as a DataFrame.

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