pub struct Client { /* private fields */ }Expand description
A client for interacting with Dremio’s Flight SQL service.
This client wraps the FlightSqlServiceClient and provides a simplified
interface for common operations such as executing SQL queries and
retrieving data as Arrow RecordBatches, or writing them to Parquet files.
Implementations§
Source§impl Client
impl Client
Sourcepub async fn new(
url: &str,
user: &str,
pass: &str,
) -> Result<Self, DremioClientError>
pub async fn new( url: &str, user: &str, pass: &str, ) -> Result<Self, DremioClientError>
Creates a new Client instance and establishes a connection to the Dremio coordinator.
§Arguments
url- The URL of the Dremio coordinator (e.g., “http://localhost:32010”).user- The username for authentication.pass- The password for authentication.
§Returns
A Result which is:
Ok(Self)if the connection is successful and authentication succeeds.Err(DremioClientError)if an error occurs during connection or authentication.
§Example
use dremio_rs::Client;
#[tokio::main]
async fn main() {
let mut client = Client::new("http://localhost:32010", "dremio", "dremio123").await.unwrap();
}Sourcepub async fn get_record_batches(
&mut self,
query: &str,
) -> Result<Vec<RecordBatch>, DremioClientError>
pub async fn get_record_batches( &mut self, query: &str, ) -> Result<Vec<RecordBatch>, DremioClientError>
Executes a SQL query against Dremio and retrieves the results as a vector of RecordBatches.
§Arguments
query- The SQL query string to execute.
§Returns
A Result which is:
Ok(Vec<RecordBatch>)containing the query results if successful.Err(DremioClientError)if an error occurs during query execution or data retrieval.
§Example
use dremio_rs::Client;
#[tokio::main]
async fn main() {
let mut client = Client::new("http://localhost:32010", "dremio", "dremio123").await.unwrap();
let batches = client.get_record_batches("SELECT * FROM sys.options").await.unwrap();
for batch in batches {
println!("{:?}", batch);
}
}Sourcepub async fn write_parquet(
&mut self,
query: &str,
path: &str,
) -> Result<(), DremioClientError>
pub async fn write_parquet( &mut self, query: &str, path: &str, ) -> Result<(), DremioClientError>
Executes a SQL query and writes the results directly to a Parquet file.
§Arguments
query- The SQL query string to execute.path- The file path where the Parquet file will be written.
§Returns
A Result which is:
Ok(())if the Parquet file is successfully written.Err(DremioClientError)if an error occurs during query execution, data retrieval, or file writing.
§Example
use dremio_rs::Client;
#[tokio::main]
async fn main() {
let mut client = Client::new("http://localhost:32010", "dremio", "dremio123").await.unwrap();
client.write_parquet("SELECT * FROM sys.options", "my_table.parquet").await.unwrap();
}Sourcepub fn inner(&self) -> &FlightSqlServiceClient<Channel>
pub fn inner(&self) -> &FlightSqlServiceClient<Channel>
Returns a shared reference to the underlying FlightSqlServiceClient.
This can be used to access more advanced Flight SQL operations not directly
exposed by the Client interface.
§Returns
A reference to the FlightSqlServiceClient<Channel>.
Auto Trait Implementations§
impl !Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
impl !UnwindSafe for Client
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> 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>
T in a tonic::Request