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 Mar 13, 2024
1 parent d55d976 commit 5dfc972
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 @@ -256,14 +256,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 @@ -276,6 +277,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>,
/// Column specification returned from the server
pub col_specs: Vec<ColumnSpec>,
/// The original size of the serialized rows in request
Expand Down Expand Up @@ -300,6 +303,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 5dfc972

Please sign in to comment.