Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions datafusion/proto-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,33 @@
//! # use datafusion_proto_common::protobuf_common;
//! # use prost::Message;
//! # fn main() -> Result<()>{
//! // Create a new ScalarValue
//! let val = ScalarValue::UInt64(Some(3));
//! let mut buffer = BytesMut::new();
//! let protobuf: protobuf_common::ScalarValue = match val {
//! ScalarValue::UInt64(Some(val)) => {
//! protobuf_common::ScalarValue{value: Some(protobuf_common::scalar_value::Value::Uint64Value(val))}
//! }
//! _ => unreachable!(),
//! };
//! // Create a new ScalarValue
//! let val = ScalarValue::UInt64(Some(3));
//! let mut buffer = BytesMut::new();
//! let protobuf: protobuf_common::ScalarValue = match val {
//! ScalarValue::UInt64(Some(val)) => protobuf_common::ScalarValue {
//! value: Some(protobuf_common::scalar_value::Value::Uint64Value(val)),
//! },
//! _ => unreachable!(),
//! };
//!
//! protobuf.encode(&mut buffer)
//! protobuf
//! .encode(&mut buffer)
//! .map_err(|e| plan_datafusion_err!("Error encoding protobuf as bytes: {e}"))?;
//! // Convert it to bytes (for sending over the network, etc.)
//! let bytes: Bytes = buffer.into();
//! // Convert it to bytes (for sending over the network, etc.)
//! let bytes: Bytes = buffer.into();
//!
//! let protobuf = protobuf_common::ScalarValue::decode(bytes).map_err(|e| plan_datafusion_err!("Error decoding ScalarValue as protobuf: {e}"))?;
//! // Decode bytes from somewhere (over network, etc.) back to ScalarValue
//! let decoded_val: ScalarValue = match protobuf.value {
//! Some(protobuf_common::scalar_value::Value::Uint64Value(val)) => ScalarValue::UInt64(Some(val)),
//! _ => unreachable!(),
//! };
//! assert_eq!(val, decoded_val);
//! let protobuf = protobuf_common::ScalarValue::decode(bytes).map_err(|e| {
//! plan_datafusion_err!("Error decoding ScalarValue as protobuf: {e}")
//! })?;
//! // Decode bytes from somewhere (over network, etc.) back to ScalarValue
//! let decoded_val: ScalarValue = match protobuf.value {
//! Some(protobuf_common::scalar_value::Value::Uint64Value(val)) => {
//! ScalarValue::UInt64(Some(val))
//! }
//! _ => unreachable!(),
//! };
//! assert_eq!(val, decoded_val);
//! # Ok(())
//! # }
//! ```
Expand Down
14 changes: 7 additions & 7 deletions datafusion/proto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@
//! # use datafusion_expr::{col, lit, Expr};
//! # use datafusion_proto::bytes::Serializeable;
//! # fn main() -> Result<()>{
//! // Create a new `Expr` a < 32
//! let expr = col("a").lt(lit(5i32));
//! // Create a new `Expr` a < 32
//! let expr = col("a").lt(lit(5i32));
//!
//! // Convert it to bytes (for sending over the network, etc.)
//! let bytes = expr.to_bytes()?;
//! // Convert it to bytes (for sending over the network, etc.)
//! let bytes = expr.to_bytes()?;
//!
//! // Decode bytes from somewhere (over network, etc.) back to Expr
//! let decoded_expr = Expr::from_bytes(&bytes)?;
//! assert_eq!(expr, decoded_expr);
//! // Decode bytes from somewhere (over network, etc.) back to Expr
//! let decoded_expr = Expr::from_bytes(&bytes)?;
//! assert_eq!(expr, decoded_expr);
//! # Ok(())
//! # }
//! ```
Expand Down
3 changes: 1 addition & 2 deletions datafusion/pruning/src/pruning_predicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ impl From<Vec<(phys_expr::Column, StatisticsType, Field)>> for RequiredColumns {
/// ```text
/// ("s1", Min, Field:s1_min)
/// ("s2", Max, field:s2_max)
///```
/// ```
///
/// And the input statistics had
/// ```text
Expand Down Expand Up @@ -5108,7 +5108,6 @@ mod tests {
///
/// `expected` is a vector of bools, where true means the row group should
/// be kept, and false means it should be pruned.
///
// TODO refactor other tests to use this to reduce boiler plate
fn prune_with_expr(
expr: Expr,
Expand Down
9 changes: 6 additions & 3 deletions datafusion/session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ use std::sync::{Arc, Weak};
/// // Given a `Session` reference, get the concrete `SessionState` reference
/// // Note: this may stop working in future versions,
/// fn session_state_from_session(session: &dyn Session) -> Result<&SessionState> {
/// session.as_any()
/// .downcast_ref::<SessionState>()
/// .ok_or_else(|| exec_datafusion_err!("Failed to downcast Session to SessionState"))
/// session
/// .as_any()
/// .downcast_ref::<SessionState>()
/// .ok_or_else(|| {
/// exec_datafusion_err!("Failed to downcast Session to SessionState")
/// })
/// }
/// ```
///
Expand Down