Skip to content

Apache DataFusion SQL Query Engine

chore(CI) Update workspace / CI to Rust 1.87 (#16068)

Davy2ea1e9552b71
diff --git a/datafusion-examples/examples/flight/flight_sql_server.rs b/datafusion-examples/examples/flight/flight_sql_server.rs
index 54e8de7177..5a573ed523 100644
--- a/datafusion-examples/examples/flight/flight_sql_server.rs
+++ b/datafusion-examples/examples/flight/flight_sql_server.rs
@@ -115,6 +115,7 @@ impl FlightSqlServiceImpl {
Ok(uuid)
}
+ #[allow(clippy::result_large_err)]
fn get_ctx<T>(&self, req: &Request<T>) -> Result<Arc<SessionContext>, Status> {
// get the token from the authorization header on Request
let auth = req
@@ -140,6 +141,7 @@ impl FlightSqlServiceImpl {
}
}
+ #[allow(clippy::result_large_err)]
fn get_plan(&self, handle: &str) -> Result<LogicalPlan, Status> {
if let Some(plan) = self.statements.get(handle) {
Ok(plan.clone())
@@ -148,6 +150,7 @@ impl FlightSqlServiceImpl {
}
}
+ #[allow(clippy::result_large_err)]
fn get_result(&self, handle: &str) -> Result<Vec<RecordBatch>, Status> {
if let Some(result) = self.results.get(handle) {
Ok(result.clone())
@@ -195,11 +198,13 @@ impl FlightSqlServiceImpl {
.unwrap()
}
+ #[allow(clippy::result_large_err)]
fn remove_plan(&self, handle: &str) -> Result<(), Status> {
self.statements.remove(&handle.to_string());
Ok(())
}
+ #[allow(clippy::result_large_err)]
fn remove_result(&self, handle: &str) -> Result<(), Status> {
self.results.remove(&handle.to_string());
Ok(())
diff --git a/datafusion/common/src/error.rs b/datafusion/common/src/error.rs
index 0b13bde2c0..b4a537fdce 100644
--- a/datafusion/common/src/error.rs
+++ b/datafusion/common/src/error.rs
@@ -397,7 +397,7 @@ impl Error for DataFusionError {
impl From<DataFusionError> for io::Error {
fn from(e: DataFusionError) -> Self {
- io::Error::new(io::ErrorKind::Other, e)
+ io::Error::other(e)
}
}
@@ -1120,8 +1120,7 @@ mod test {
);
// assert wrapping other Error
- let generic_error: GenericError =
- Box::new(std::io::Error::new(std::io::ErrorKind::Other, "io error"));
+ let generic_error: GenericError = Box::new(std::io::Error::other("io error"));
let datafusion_error: DataFusionError = generic_error.into();
println!("{}", datafusion_error.strip_backtrace());
assert_eq!(
@@ -1132,8 +1131,7 @@ mod test {
#[test]
fn external_error_no_recursive() {
- let generic_error_1: GenericError =
- Box::new(std::io::Error::new(std::io::ErrorKind::Other, "io error"));
+ let generic_error_1: GenericError = Box::new(std::io::Error::other("io error"));
let external_error_1: DataFusionError = generic_error_1.into();
let generic_error_2: GenericError = Box::new(external_error_1);
let external_error_2: DataFusionError = generic_error_2.into();
diff --git a/datafusion/common/src/stats.rs b/datafusion/common/src/stats.rs
index c67b35a263..a6d132ef51 100644
--- a/datafusion/common/src/stats.rs
+++ b/datafusion/common/src/stats.rs
@@ -352,6 +352,7 @@ impl Statistics {
return self;
};
+ #[allow(clippy::large_enum_variant)]
enum Slot {
/// The column is taken and put into the specified statistics location
Taken(usize),
diff --git a/datafusion/datasource-avro/src/avro_to_arrow/arrow_array_reader.rs b/datafusion/datasource-avro/src/avro_to_arrow/arrow_array_reader.rs
index caaf60d634..36553b36bc 100644
--- a/datafusion/datasource-avro/src/avro_to_arrow/arrow_array_reader.rs
+++ b/datafusion/datasource-avro/src/avro_to_arrow/arrow_array_reader.rs
@@ -21,7 +21,7 @@ use apache_avro::schema::RecordSchema;
use apache_avro::{
schema::{Schema as AvroSchema, SchemaKind},
types::Value,
- AvroResult, Error as AvroError, Reader as AvroReader,
+ Error as AvroError, Reader as AvroReader,
};
use arrow::array::{
make_array, Array, ArrayBuilder, ArrayData, ArrayDataBuilder, ArrayRef,
@@ -938,40 +938,31 @@ fn resolve_string(v: &Value) -> ArrowResult<Option<String>> {
.map_err(|e| SchemaError(format!("expected resolvable string : {e:?}")))
}
-fn resolve_u8(v: &Value) -> AvroResult<u8> {
- let int = match v {
- Value::Int(n) => Ok(Value::Int(*n)),
- Value::Long(n) => Ok(Value::Int(*n as i32)),
- other => Err(AvroError::GetU8(other.into())),
- }?;
- if let Value::Int(n) = int {
- if n >= 0 && n <= From::from(u8::MAX) {
- return Ok(n as u8);
- }
- }
+fn resolve_u8(v: &Value) -> Option<u8> {
+ let v = match v {
+ Value::Union(_, inner) => inner.as_ref(),
+ _ => v,
+ };
- Err(AvroError::GetU8(int.into()))
+ match v {
+ Value::Int(n) => u8::try_from(*n).ok(),
+ Value::Long(n) => u8::try_from(*n).ok(),
+ _ => None,
+ }
}
fn resolve_bytes(v: &Value) -> Option<Vec<u8>> {
- let v = if let Value::Union(_, b) = v { b } else { v };
+ let v = match v {
+ Value::Union(_, inner) => inner.as_ref(),
+ _ => v,
+ };
+
match v {
- Value::Bytes(_) => Ok(v.clone()),
- Value::String(s) => Ok(Value::Bytes(s.clone().into_bytes())),
- Value::Array(items) => Ok(Value::Bytes(
- items
- .iter()
- .map(resolve_u8)
- .collect::<Result<Vec<_>, _>>()
- .ok()?,
- )),
- other => Err(AvroError::GetBytes(other.into())),
- }
- .ok()
- .and_then(|v| match v {
- Value::Bytes(s) => Some(s),
+ Value::Bytes(bytes) => Some(bytes.clone()),
+ Value::String(s) => Some(s.as_bytes().to_vec()),
+ Value::Array(items) => items.iter().map(resolve_u8).collect::<Option<Vec<u8>>>(),
_ => None,
- })
+ }
}
fn resolve_fixed(v: &Value, size: usize) -> Option<Vec<u8>> {
diff --git a/datafusion/expr-common/src/accumulator.rs b/datafusion/expr-common/src/accumulator.rs
index 3a63c32894..2829a9416f 100644
--- a/datafusion/expr-common/src/accumulator.rs
+++ b/datafusion/expr-common/src/accumulator.rs
@@ -42,7 +42,6 @@ use std::fmt::Debug;
/// [`state`] and combine the state from multiple accumulators
/// via [`merge_batch`], as part of efficient multi-phase grouping.
///
-/// [`GroupsAccumulator`]: crate::GroupsAccumulator
/// [`update_batch`]: Self::update_batch
/// [`retract_batch`]: Self::retract_batch
/// [`state`]: Self::state
diff --git a/datafusion/expr/src/planner.rs b/datafusion/expr/src/planner.rs
index a2ed0592ef..4c03f91931 100644
--- a/datafusion/expr/src/planner.rs
+++ b/datafusion/expr/src/planner.rs
@@ -312,6 +312,7 @@ pub struct RawWindowExpr {
/// Result of planning a raw expr with [`ExprPlanner`]
#[derive(Debug, Clone)]
+#[allow(clippy::large_enum_variant)]
pub enum PlannerResult<T> {
/// The raw expression was successfully planned as a new [`Expr`]
Planned(Expr),
diff --git a/datafusion/expr/src/simplify.rs b/datafusion/expr/src/simplify.rs
index 467ce8bf53..411dbbdc40 100644
--- a/datafusion/expr/src/simplify.rs
+++ b/datafusion/expr/src/simplify.rs
@@ -110,6 +110,7 @@ impl SimplifyInfo for SimplifyContext<'_> {
/// Was the expression simplified?
#[derive(Debug)]
+#[allow(clippy::large_enum_variant)]
pub enum ExprSimplifyResult {
/// The function call was simplified to an entirely new Expr
Simplified(Expr),
diff --git a/datafusion/expr/src/window_state.rs b/datafusion/expr/src/window_state.rs
index f1d0ead23a..4c37cc6b60 100644
--- a/datafusion/expr/src/window_state.rs
+++ b/datafusion/expr/src/window_state.rs
@@ -193,11 +193,7 @@ impl WindowFrameContext {
// UNBOUNDED PRECEDING
WindowFrameBound::Preceding(ScalarValue::UInt64(None)) => 0,
WindowFrameBound::Preceding(ScalarValue::UInt64(Some(n))) => {
- if idx >= n as usize {
- idx - n as usize
- } else {
- 0
- }
+ idx.saturating_sub(n as usize)
}
WindowFrameBound::CurrentRow => idx,
// UNBOUNDED FOLLOWING
@@ -602,11 +598,7 @@ impl WindowFrameStateGroups {
// Find the group index of the frame boundary:
let group_idx = if SEARCH_SIDE {
- if self.current_group_idx > delta {
- self.current_group_idx - delta
- } else {
- 0
- }
+ self.current_group_idx.saturating_sub(delta)
} else {
self.current_group_idx + delta
};
diff --git a/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs b/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs
index ad4fbb7bde..04ca471309 100644
--- a/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs
+++ b/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs
@@ -520,6 +520,7 @@ struct ConstEvaluator<'a> {
#[allow(dead_code)]
/// The simplify result of ConstEvaluator
+#[allow(clippy::large_enum_variant)]
enum ConstSimplifyResult {
// Expr was simplified and contains the new expression
Simplified(ScalarValue),
diff --git a/datafusion/physical-plan/src/aggregates/mod.rs b/datafusion/physical-plan/src/aggregates/mod.rs
index a2616de5a6..2062e2208b 100644
--- a/datafusion/physical-plan/src/aggregates/mod.rs
+++ b/datafusion/physical-plan/src/aggregates/mod.rs
@@ -346,6 +346,7 @@ impl PartialEq for PhysicalGroupBy {
}
}
+#[allow(clippy::large_enum_variant)]
enum StreamType {
AggregateStream(AggregateStream),
GroupedHash(GroupedHashAggregateStream),
diff --git a/datafusion/sql/src/resolve.rs b/datafusion/sql/src/resolve.rs
index 96012a92c0..9e909f66fa 100644
--- a/datafusion/sql/src/resolve.rs
+++ b/datafusion/sql/src/resolve.rs
@@ -78,7 +78,7 @@ impl Visitor for RelationVisitor {
if !with.recursive {
// This is a bit hackish as the CTE will be visited again as part of visiting `q`,
// but thankfully `insert_relation` is idempotent.
- cte.visit(self);
+ let _ = cte.visit(self);
}
self.ctes_in_scope
.push(ObjectName::from(vec![cte.alias.name.clone()]));
@@ -143,7 +143,7 @@ fn visit_statement(statement: &DFStatement, visitor: &mut RelationVisitor) {
visitor.insert_relation(table_name);
}
CopyToSource::Query(query) => {
- query.visit(visitor);
+ let _ = query.visit(visitor);
}
},
DFStatement::Explain(explain) => visit_statement(&explain.statement, visitor),
diff --git a/datafusion/sql/src/select.rs b/datafusion/sql/src/select.rs
index c8837c9477..9fad274b51 100644
--- a/datafusion/sql/src/select.rs
+++ b/datafusion/sql/src/select.rs
@@ -885,7 +885,7 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
| SelectItem::UnnamedExpr(expr) = proj
{
let mut err = None;
- visit_expressions_mut(expr, |expr| {
+ let _ = visit_expressions_mut(expr, |expr| {
if let SQLExpr::Function(f) = expr {
if let Some(WindowType::NamedWindow(ident)) = &f.over {
let normalized_ident =
diff --git a/datafusion/sql/src/unparser/ast.rs b/datafusion/sql/src/unparser/ast.rs
index 3a294cb06a..d9ade822aa 100644
--- a/datafusion/sql/src/unparser/ast.rs
+++ b/datafusion/sql/src/unparser/ast.rs
@@ -213,7 +213,7 @@ impl SelectBuilder {
value: &ast::Expr,
) -> &mut Self {
if let Some(selection) = &mut self.selection {
- visit_expressions_mut(selection, |expr| {
+ let _ = visit_expressions_mut(selection, |expr| {
if expr == existing_expr {
*expr = value.clone();
}
@@ -398,6 +398,7 @@ pub struct RelationBuilder {
#[allow(dead_code)]
#[derive(Clone)]
+#[allow(clippy::large_enum_variant)]
enum TableFactorBuilder {
Table(TableRelationBuilder),
Derived(DerivedRelationBuilder),
diff --git a/datafusion/sql/src/unparser/extension_unparser.rs b/datafusion/sql/src/unparser/extension_unparser.rs
index f7deabe7c9..b778130ca5 100644
--- a/datafusion/sql/src/unparser/extension_unparser.rs
+++ b/datafusion/sql/src/unparser/extension_unparser.rs
@@ -64,6 +64,7 @@ pub enum UnparseWithinStatementResult {
}
/// The result of unparsing a custom logical node to a statement.
+#[allow(clippy::large_enum_variant)]
pub enum UnparseToStatementResult {
/// If the custom logical node was successfully unparsed to a statement.
Modified(Statement),
diff --git a/rust-toolchain.toml b/rust-toolchain.toml
index a85e6fa542..c52dd7322d 100644
--- a/rust-toolchain.toml
+++ b/rust-toolchain.toml
@@ -19,5 +19,5 @@
# to compile this workspace and run CI jobs.
[toolchain]
-channel = "1.86.0"
+channel = "1.87.0"
components = ["rustfmt", "clippy"]