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
17 changes: 9 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,21 @@ url = "2.5.7"
uuid = "1.23"
zstd = { version = "0.13", default-features = false }

# Keep this list sorted alphabetically.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorting makes it easier to check if a lint already has been added

[workspace.lints.clippy]
# https://github.com/apache/datafusion/issues/18881
allow_attributes = "warn"
assigning_clones = "warn"
inefficient_to_string = "warn"
# Detects large stack-allocated futures that may cause stack overflow crashes (see threshold in clippy.toml)
large_futures = "warn"
used_underscore_binding = "warn"
or_fun_call = "warn"
unnecessary_lazy_evaluations = "warn"
uninlined_format_args = "warn"
inefficient_to_string = "warn"
# https://github.com/apache/datafusion/issues/18503
needless_pass_by_value = "warn"
# https://github.com/apache/datafusion/issues/18881
allow_attributes = "warn"
assigning_clones = "warn"
or_fun_call = "warn"
uninlined_format_args = "warn"
unnecessary_lazy_evaluations = "warn"
unused_async = "warn"
used_underscore_binding = "warn"

[workspace.lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = [
Expand Down
6 changes: 6 additions & 0 deletions datafusion/proto-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ rust-version = { workspace = true }
[package.metadata.docs.rs]
all-features = true

# Note: add additional linter rules in lib.rs.
# Rust does not support workspace + new linter rules in subcrates yet
# https://github.com/rust-lang/cargo/issues/13157
[lints]
workspace = true

[lib]
name = "datafusion_proto_common"

Expand Down
4 changes: 1 addition & 3 deletions datafusion/proto-common/src/from_proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1259,9 +1259,7 @@ fn vec_to_array<T, const N: usize>(v: Vec<T>) -> [T; N] {
}

/// Converts a vector of `protobuf::Field`s to `Arc<arrow::Field>`s.
pub fn parse_proto_fields_to_fields<'a, I>(
fields: I,
) -> std::result::Result<Vec<Field>, Error>
pub fn parse_proto_fields_to_fields<'a, I>(fields: I) -> Result<Vec<Field>, Error>
where
I: IntoIterator<Item = &'a protobuf::Field>,
{
Expand Down
1 change: 1 addition & 0 deletions datafusion/proto-common/src/generated/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// This code is generated so we don't want to fix any lint violations manually
#[allow(clippy::allow_attributes)]
#[allow(clippy::all)]
#[allow(unused_qualifications)]
#[rustfmt::skip]
pub mod datafusion_proto_common {
include!("prost.rs");
Expand Down
52 changes: 16 additions & 36 deletions datafusion/proto-common/src/to_proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl TryFrom<&DataType> for protobuf::ArrowType {
}
}

impl TryFrom<&DataType> for protobuf::arrow_type::ArrowTypeEnum {
impl TryFrom<&DataType> for ArrowTypeEnum {
type Error = Error;

fn try_from(val: &DataType) -> Result<Self, Self::Error> {
Expand Down Expand Up @@ -439,9 +439,7 @@ impl TryFrom<&ScalarValue> for protobuf::ScalarValue {
})
}
None => Ok(protobuf::ScalarValue {
value: Some(protobuf::scalar_value::Value::NullValue(
(&data_type).try_into()?,
)),
value: Some(Value::NullValue((&data_type).try_into()?)),
}),
},
ScalarValue::Decimal64(val, p, s) => match *val {
Expand All @@ -457,9 +455,7 @@ impl TryFrom<&ScalarValue> for protobuf::ScalarValue {
})
}
None => Ok(protobuf::ScalarValue {
value: Some(protobuf::scalar_value::Value::NullValue(
(&data_type).try_into()?,
)),
value: Some(Value::NullValue((&data_type).try_into()?)),
}),
},
ScalarValue::Decimal128(val, p, s) => match *val {
Expand All @@ -475,9 +471,7 @@ impl TryFrom<&ScalarValue> for protobuf::ScalarValue {
})
}
None => Ok(protobuf::ScalarValue {
value: Some(protobuf::scalar_value::Value::NullValue(
(&data_type).try_into()?,
)),
value: Some(Value::NullValue((&data_type).try_into()?)),
}),
},
ScalarValue::Decimal256(val, p, s) => match *val {
Expand All @@ -493,9 +487,7 @@ impl TryFrom<&ScalarValue> for protobuf::ScalarValue {
})
}
None => Ok(protobuf::ScalarValue {
value: Some(protobuf::scalar_value::Value::NullValue(
(&data_type).try_into()?,
)),
value: Some(Value::NullValue((&data_type).try_into()?)),
}),
},
ScalarValue::Date64(val) => {
Expand Down Expand Up @@ -788,8 +780,8 @@ impl From<&Precision<usize>> for protobuf::Precision {
}
}

impl From<&Precision<datafusion_common::ScalarValue>> for protobuf::Precision {
fn from(s: &Precision<datafusion_common::ScalarValue>) -> protobuf::Precision {
impl From<&Precision<ScalarValue>> for protobuf::Precision {
fn from(s: &Precision<ScalarValue>) -> protobuf::Precision {
match s {
Precision::Exact(val) => protobuf::Precision {
precision_info: protobuf::PrecisionInfo::Exact.into(),
Expand Down Expand Up @@ -1076,16 +1068,14 @@ impl TryFrom<&JsonOptions> for protobuf::JsonOptions {

/// Creates a scalar protobuf value from an optional value (T), and
/// encoding None as the appropriate datatype
fn create_proto_scalar<I, T: FnOnce(&I) -> protobuf::scalar_value::Value>(
fn create_proto_scalar<I, T: FnOnce(&I) -> Value>(
v: Option<&I>,
null_arrow_type: &DataType,
constructor: T,
) -> Result<protobuf::ScalarValue, Error> {
let value = v
.map(constructor)
.unwrap_or(protobuf::scalar_value::Value::NullValue(
null_arrow_type.try_into()?,
));
.unwrap_or(Value::NullValue(null_arrow_type.try_into()?));

Ok(protobuf::ScalarValue { value: Some(value) })
}
Expand Down Expand Up @@ -1141,35 +1131,25 @@ fn encode_scalar_nested_value(

match val {
ScalarValue::List(_) => Ok(protobuf::ScalarValue {
value: Some(protobuf::scalar_value::Value::ListValue(scalar_list_value)),
value: Some(Value::ListValue(scalar_list_value)),
}),
ScalarValue::LargeList(_) => Ok(protobuf::ScalarValue {
value: Some(protobuf::scalar_value::Value::LargeListValue(
scalar_list_value,
)),
value: Some(Value::LargeListValue(scalar_list_value)),
}),
ScalarValue::FixedSizeList(_) => Ok(protobuf::ScalarValue {
value: Some(protobuf::scalar_value::Value::FixedSizeListValue(
scalar_list_value,
)),
value: Some(Value::FixedSizeListValue(scalar_list_value)),
}),
ScalarValue::ListView(_) => Ok(protobuf::ScalarValue {
value: Some(protobuf::scalar_value::Value::ListViewValue(
scalar_list_value,
)),
value: Some(Value::ListViewValue(scalar_list_value)),
}),
ScalarValue::LargeListView(_) => Ok(protobuf::ScalarValue {
value: Some(protobuf::scalar_value::Value::LargeListViewValue(
scalar_list_value,
)),
value: Some(Value::LargeListViewValue(scalar_list_value)),
}),
ScalarValue::Struct(_) => Ok(protobuf::ScalarValue {
value: Some(protobuf::scalar_value::Value::StructValue(
scalar_list_value,
)),
value: Some(Value::StructValue(scalar_list_value)),
}),
ScalarValue::Map(_) => Ok(protobuf::ScalarValue {
value: Some(protobuf::scalar_value::Value::MapValue(scalar_list_value)),
value: Some(Value::MapValue(scalar_list_value)),
}),
_ => unreachable!(),
}
Expand Down
6 changes: 6 additions & 0 deletions datafusion/proto-models/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ rust-version = { workspace = true }
[package.metadata.docs.rs]
all-features = true

# Note: add additional linter rules in lib.rs.
# Rust does not support workspace + new linter rules in subcrates yet
# https://github.com/rust-lang/cargo/issues/13157
[lints]
workspace = true

[lib]
name = "datafusion_proto_models"

Expand Down
1 change: 1 addition & 0 deletions datafusion/proto-models/src/generated/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// This code is generated so we don't want to fix any lint violations manually
#[allow(clippy::allow_attributes)]
#[allow(clippy::all)]
#[allow(unused_qualifications)]
#[rustfmt::skip]
pub mod datafusion {
include!("prost.rs");
Expand Down
6 changes: 6 additions & 0 deletions datafusion/proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ rust-version = { workspace = true }
[package.metadata.docs.rs]
all-features = true

# Note: add additional linter rules in lib.rs.
# Rust does not support workspace + new linter rules in subcrates yet
# https://github.com/rust-lang/cargo/issues/13157
[lints]
workspace = true

[lib]
name = "datafusion_proto"

Expand Down
1 change: 1 addition & 0 deletions datafusion/proto/src/bytes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ pub fn physical_plan_to_bytes_with_extension_codec(

/// Serialize a PhysicalPlan as bytes, using the provided extension codec
/// and protobuf converter.
#[expect(clippy::needless_pass_by_value)] // Taking the plan by value is part of the public API
pub fn physical_plan_to_bytes_with_proto_converter(
plan: Arc<dyn ExecutionPlan>,
extension_codec: &dyn PhysicalExtensionCodec,
Expand Down
2 changes: 1 addition & 1 deletion datafusion/proto/src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ pub trait FromProto<T>: Sized {
/// versa). Mirrors [`TryFrom`].
pub trait TryFromProto<T>: Sized {
type Error;
fn try_from_proto(value: T) -> std::result::Result<Self, Self::Error>;
fn try_from_proto(value: T) -> Result<Self, Self::Error>;
}
8 changes: 3 additions & 5 deletions datafusion/proto/src/logical_plan/file_formats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,11 +767,9 @@ mod parquet {
exec_datafusion_err!("Failed to decode TableParquetOptionsProto: {e:?}")
})?;
let options = TableParquetOptions::try_from_proto(&proto)?;
Ok(Arc::new(
datafusion_datasource_parquet::file_format::ParquetFormatFactory {
options: Some(options),
},
))
Ok(Arc::new(ParquetFormatFactory {
options: Some(options),
}))
}

fn try_encode_file_format(
Expand Down
6 changes: 3 additions & 3 deletions datafusion/proto/src/logical_plan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ impl AsLogicalPlan for LogicalPlanNode {
)?
.build()
}
LogicalPlanType::CustomScan(scan) => {
CustomScan(scan) => {
let schema: Schema = convert_required!(scan.schema)?;
let schema = Arc::new(schema);
let mut projection = None;
Expand Down Expand Up @@ -1272,7 +1272,7 @@ impl AsLogicalPlan for LogicalPlanNode {
LogicalPlanType::Dml(dml_node) => {
let write_op =
from_proto::parse_write_op(dml_node, ctx, extension_codec)?;
Ok(LogicalPlan::Dml(datafusion_expr::DmlStatement::new(
Ok(LogicalPlan::Dml(DmlStatement::new(
from_table_reference(dml_node.table_name.as_ref(), "DML ")?,
to_table_source(&dml_node.target, ctx, extension_codec)?,
write_op,
Expand Down Expand Up @@ -1479,7 +1479,7 @@ impl AsLogicalPlan for LogicalPlanNode {

Ok(LogicalPlanNode {
logical_plan_type: Some(LogicalPlanType::CteWorkTableScan(
protobuf::CteWorkTableScanNode {
CteWorkTableScanNode {
name,
schema: Some(schema),
},
Expand Down
6 changes: 2 additions & 4 deletions datafusion/proto/src/logical_plan/to_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
//! DataFusion logical plans to be serialized and transmitted between
//! processes.

use std::collections::HashMap;

use datafusion_common::{NullEquality, SplitPoint, TableReference, UnnestOptions};
use datafusion_expr::dml::{
MergeIntoAction, MergeIntoClause, MergeIntoClauseKind, MergeIntoOp,
Expand Down Expand Up @@ -230,7 +228,7 @@ pub fn serialize_expr(
metadata: metadata
.as_ref()
.map(|m| m.to_hashmap())
.unwrap_or(HashMap::new()),
.unwrap_or_default(),
});
protobuf::LogicalExprNode {
expr_type: Some(ExprType::Alias(alias)),
Expand Down Expand Up @@ -661,7 +659,7 @@ pub fn serialize_expr(
metadata: field
.as_ref()
.map(|f| f.metadata().clone())
.unwrap_or(HashMap::new()),
.unwrap_or_default(),
})),
},
Expr::Lambda(Lambda { params, body }) => protobuf::LogicalExprNode {
Expand Down
12 changes: 6 additions & 6 deletions datafusion/proto/tests/cases/roundtrip_logical_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ fn roundtrip_expr_test_with_codec(
let round_trip: Expr =
from_proto::parse_expr(&proto, ctx.task_ctx().as_ref(), codec).unwrap();

assert_eq!(format!("{:?}", initial_struct), format!("{round_trip:?}"));
assert_eq!(format!("{initial_struct:?}"), format!("{round_trip:?}"));

roundtrip_json_test(&proto);
}
Expand Down Expand Up @@ -1704,7 +1704,7 @@ pub mod proto {
pub expr: Option<datafusion_proto::protobuf::LogicalExprNode>,
}

#[allow(dead_code)]
#[expect(dead_code)]
#[derive(Clone, PartialEq, Eq, ::prost::Message)]
pub struct TopKExecProto {
#[prost(uint64, tag = "1")]
Expand Down Expand Up @@ -2517,7 +2517,7 @@ fn roundtrip_null_scalar_values() {
for test_case in test_types.into_iter() {
let proto_scalar: protobuf::ScalarValue = (&test_case).try_into().unwrap();
let returned_scalar: ScalarValue = (&proto_scalar).try_into().unwrap();
assert_eq!(format!("{:?}", test_case), format!("{returned_scalar:?}"));
assert_eq!(format!("{test_case:?}"), format!("{returned_scalar:?}"));
}
}

Expand Down Expand Up @@ -3024,7 +3024,7 @@ fn roundtrip_scalar_udf_extension_codec() {
from_proto::parse_expr(&proto, ctx.task_ctx().as_ref(), &UDFExtensionCodec)
.expect("parse expr");

assert_eq!(format!("{:?}", test_expr), format!("{round_trip:?}"));
assert_eq!(format!("{test_expr:?}"), format!("{round_trip:?}"));
roundtrip_json_test(&proto);
}

Expand All @@ -3038,7 +3038,7 @@ fn roundtrip_aggregate_udf_extension_codec() {
from_proto::parse_expr(&proto, ctx.task_ctx().as_ref(), &UDFExtensionCodec)
.expect("parse expr");

assert_eq!(format!("{:?}", test_expr), format!("{round_trip:?}"));
assert_eq!(format!("{test_expr:?}"), format!("{round_trip:?}"));
roundtrip_json_test(&proto);
}

Expand Down Expand Up @@ -3147,7 +3147,7 @@ fn roundtrip_higher_order_udf_extension_codec() {
from_proto::parse_expr(&proto, ctx.task_ctx().as_ref(), &UDFExtensionCodec)
.expect("parse expr");

assert_eq!(format!("{:?}", test_expr), format!("{round_trip:?}"));
assert_eq!(format!("{test_expr:?}"), format!("{round_trip:?}"));
roundtrip_json_test(&proto);
}

Expand Down
Loading
Loading