pub struct SparkSession { /* private fields */ }Expand description
Represents a logical connection to a Spark Connect backend.
SparkSession is the main entry point for executing commands, analyzing
queries, and retrieving results from Spark Connect.
It wraps an internal SparkClient and tracks session
state (such as the session_id).
§Examples
use spark_connect::SparkSessionBuilder;
let session = SparkSessionBuilder::new("sc://localhost:15002")
.build()
.await
.unwrap();
println!("Session ID: {}", session.session_id());Implementations§
Source§impl SparkSession
impl SparkSession
Sourcepub fn session_id(&self) -> String
pub fn session_id(&self) -> String
Returns the unique session identifier for this connection.
Sourcepub async fn sql(
&self,
query: &str,
params: Vec<Literal>,
) -> Result<Plan, SparkError>
pub async fn sql( &self, query: &str, params: Vec<Literal>, ) -> Result<Plan, SparkError>
Execute a SQL query and return a lazy plan.
Sourcepub fn query(&self, query: &str) -> SqlQueryBuilder<'_>
pub fn query(&self, query: &str) -> SqlQueryBuilder<'_>
Alternative “sqlx-like” query interface.
Returns a SqlQueryBuilder to bind() parameters and execute().
Sourcepub async fn collect(&self, plan: Plan) -> Result<Vec<RecordBatch>, SparkError>
pub async fn collect(&self, plan: Plan) -> Result<Vec<RecordBatch>, SparkError>
Collect the results from a lazy plan.
Sourcepub async fn interrupt_all(&self) -> Result<Vec<String>, SparkError>
pub async fn interrupt_all(&self) -> Result<Vec<String>, SparkError>
Interrupt all running operations.
Sourcepub async fn interrupt_operation(
&self,
op_id: &str,
) -> Result<Vec<String>, SparkError>
pub async fn interrupt_operation( &self, op_id: &str, ) -> Result<Vec<String>, SparkError>
Interrupt a specific operation by ID.
Sourcepub async fn version(&self) -> Result<String, SparkError>
pub async fn version(&self) -> Result<String, SparkError>
Request the version of the Spark Connect server.
Trait Implementations§
Source§impl Clone for SparkSession
impl Clone for SparkSession
Source§fn clone(&self) -> SparkSession
fn clone(&self) -> SparkSession
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SparkSession
impl !RefUnwindSafe for SparkSession
impl Send for SparkSession
impl Sync for SparkSession
impl Unpin for SparkSession
impl !UnwindSafe for SparkSession
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request