Struct light_snowflake_connector::QueryResponse
source · pub struct QueryResponse { /* private fields */ }
Expand description
The result of SQL that returns rows
The first partition is included immediately, but additional partitions are streamed lazily and incur additional IO.
You might consider using QueryResponse::only_partition
if you only need one partition.
Implementations§
source§impl QueryResponse
impl QueryResponse
sourcepub fn num_columns(&self) -> usize
pub fn num_columns(&self) -> usize
Get the number of columns
sourcepub fn num_partitions(&self) -> usize
pub fn num_partitions(&self) -> usize
Get the number of columns in the response
sourcepub fn column_types(&self) -> &[ColumnType]
pub fn column_types(&self) -> &[ColumnType]
Column types in the result set
In most cases Cell should already expose the data you need, but if you use the raw strings or want information about nullability, etc, this can be useful.
sourcepub fn only_partition(self) -> SnowflakeResult<Partition>
pub fn only_partition(self) -> SnowflakeResult<Partition>
A convenience method to assert that there is only one partition and return it
This never causes IO, is not async, and can only error with SnowflakeError::MultiplePartitions
sourcepub async fn partition(
&self,
index: usize
) -> SnowflakeResult<Option<Partition>>
pub async fn partition( &self, index: usize ) -> SnowflakeResult<Option<Partition>>
Get a single partition from the response
If this is the first partition, you get it immediately, otherwise it will incur an additional request to get the partition
Returns an error if the requested partition does not exist.
sourcepub fn partitions(
&self
) -> impl TryStream<Ok = Partition, Error = SnowflakeError> + '_
pub fn partitions( &self ) -> impl TryStream<Ok = Partition, Error = SnowflakeError> + '_
Stream over all partitions in the response
This incurs IO, so try to only use this once.
In order to improve concurrency, this will buffer one partition, so you can have one partition in flight while processing another.
sourcepub async fn concat_partitions(&self) -> SnowflakeResult<Partition>
pub async fn concat_partitions(&self) -> SnowflakeResult<Partition>
Concatenate all partitions into a single partition
This incurs IO, so try to only use this once.
This could use an unbounded amount of memory, but it could save time for uses cases requiring multiple passes.
sourcepub fn rows(
&self
) -> impl TryStream<Ok = Vec<Cell>, Error = SnowflakeError> + '_
pub fn rows( &self ) -> impl TryStream<Ok = Vec<Cell>, Error = SnowflakeError> + '_
Stream over all rows in the response
This incurs IO, so try to only use this once.
In order to improve concurrency, this will buffer one partition, so you can have one partition in flight while processing another.
If you only need one partition, it may be simpler to use partition
and then stream over the rows in that partition.
sourcepub fn json_tables(
&self
) -> impl TryStream<Ok = Vec<Value>, Error = SnowflakeError> + '_
pub fn json_tables( &self ) -> impl TryStream<Ok = Vec<Value>, Error = SnowflakeError> + '_
Stream over all rows in the response as JSON tables
This incurs IO, so try to only use this once.
In order to improve concurrency, this will buffer one partition, so you can have one partition in flight while processing another.
sourcepub fn json_objects(
&self
) -> impl TryStream<Ok = Value, Error = SnowflakeError> + '_
pub fn json_objects( &self ) -> impl TryStream<Ok = Value, Error = SnowflakeError> + '_
Stream over all rows in the response as JSON objects
This incurs IO, so try to only use this once.
In order to improve concurrency, this will buffer one partition, so you can have one partition in flight while processing another.