Skip to content

Commit

Permalink
query_result: store table_spec
Browse files Browse the repository at this point in the history
Before the previous commit, table spec was available in column specs.
As it's no longer held there, a public field is added for users to still
be able to retrieve this information from QueryResult.
  • Loading branch information
wprzytula committed Aug 12, 2024
1 parent 976fe5d commit abe53f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scylla/src/transport/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,15 @@ impl NonErrorQueryResponse {
}

pub(crate) fn into_query_result(self) -> Result<QueryResult, QueryError> {
let (rows, paging_state, col_specs, serialized_size) = match self.response {
let (rows, paging_state, table_spec, col_specs, serialized_size) = match self.response {
NonErrorResponse::Result(result::Result::Rows(rs)) => (
Some(rs.rows),
rs.metadata.paging_state,
rs.metadata.table_spec,
rs.metadata.col_specs,
rs.serialized_size,
),
NonErrorResponse::Result(_) => (None, None, vec![], 0),
NonErrorResponse::Result(_) => (None, None, None, vec![], 0),
_ => {
return Err(QueryError::ProtocolError(
"Unexpected server response, expected Result or Error",
Expand All @@ -278,6 +279,7 @@ impl NonErrorQueryResponse {
warnings: self.warnings,
tracing_id: self.tracing_id,
paging_state,
table_spec,
col_specs,
serialized_size,
})
Expand Down
4 changes: 4 additions & 0 deletions scylla/src/transport/query_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::frame::response::result::ColumnSpec;
use crate::frame::response::result::Row;
use crate::transport::session::{IntoTypedRows, TypedRowIter};
use bytes::Bytes;
use scylla_cql::frame::response::result::TableSpec;
use thiserror::Error;
use uuid::Uuid;

Expand All @@ -21,6 +22,8 @@ pub struct QueryResult {
pub tracing_id: Option<Uuid>,
/// Paging state returned from the server
pub paging_state: Option<Bytes>,
/// Table specification returned from the server
pub table_spec: Option<TableSpec<'static>>,
/// Column specification returned from the server
pub col_specs: Vec<ColumnSpec>,
/// The original size of the serialized rows in request
Expand Down Expand Up @@ -305,6 +308,7 @@ mod tests {
warnings: vec![],
tracing_id: None,
paging_state: None,
table_spec: None,
col_specs: vec![column_spec],
serialized_size: 0,
}
Expand Down

0 comments on commit abe53f6

Please sign in to comment.