Skip to content

Commit

Permalink
clippy: apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
askalt committed Feb 5, 2025
1 parent f7531cb commit 8c23e1f
Show file tree
Hide file tree
Showing 59 changed files with 91 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub struct AvroArrowArrayReader<'a, R: Read> {
schema_lookup: BTreeMap<String, usize>,
}

impl<'a, R: Read> AvroArrowArrayReader<'a, R> {
impl<R: Read> AvroArrowArrayReader<'_, R> {
pub fn try_new(
reader: R,
schema: SchemaRef,
Expand Down
4 changes: 2 additions & 2 deletions datafusion/core/src/datasource/avro_to_arrow/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub struct Reader<'a, R: Read> {
batch_size: usize,
}

impl<'a, R: Read> Reader<'a, R> {
impl<R: Read> Reader<'_, R> {
/// Create a new Avro Reader from any value that implements the `Read` trait.
///
/// If reading a `File`, you can customise the Reader, such as to enable schema
Expand Down Expand Up @@ -157,7 +157,7 @@ impl<'a, R: Read> Reader<'a, R> {
}
}

impl<'a, R: Read> Iterator for Reader<'a, R> {
impl<R: Read> Iterator for Reader<'_, R> {
type Item = ArrowResult<RecordBatch>;

/// Returns the next batch of results (defined by `self.batch_size`), or `None` if there
Expand Down
4 changes: 2 additions & 2 deletions datafusion/execution/src/metrics/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ pub struct ScopedTimerGuard<'a> {
start: Option<Instant>,
}

impl<'a> ScopedTimerGuard<'a> {
impl ScopedTimerGuard<'_> {
/// Stop the timer timing and record the time taken
pub fn stop(&mut self) {
if let Some(start) = self.start.take() {
Expand All @@ -332,7 +332,7 @@ impl<'a> ScopedTimerGuard<'a> {
}
}

impl<'a> Drop for ScopedTimerGuard<'a> {
impl Drop for ScopedTimerGuard<'_> {
fn drop(&mut self) {
self.stop()
}
Expand Down
2 changes: 1 addition & 1 deletion datafusion/expr/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1865,7 +1865,7 @@ macro_rules! expr_vec_fmt {
}

struct SchemaDisplay<'a>(&'a Expr);
impl<'a> Display for SchemaDisplay<'a> {
impl Display for SchemaDisplay<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self.0 {
// The same as Display
Expand Down
2 changes: 1 addition & 1 deletion datafusion/expr/src/logical_plan/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl DdlStatement {
/// See [crate::LogicalPlan::display] for an example
pub fn display(&self) -> impl fmt::Display + '_ {
struct Wrapper<'a>(&'a DdlStatement);
impl<'a> Display for Wrapper<'a> {
impl Display for Wrapper<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.0 {
DdlStatement::CreateExternalTable(CreateExternalTable {
Expand Down
2 changes: 1 addition & 1 deletion datafusion/expr/src/logical_plan/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl<'n, 'a, 'b> TreeNodeVisitor<'n> for IndentVisitor<'a, 'b> {
pub fn display_schema(schema: &Schema) -> impl fmt::Display + '_ {
struct Wrapper<'a>(&'a Schema);

impl<'a> fmt::Display for Wrapper<'a> {
impl fmt::Display for Wrapper<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "[")?;
for (idx, field) in self.0.fields().iter().enumerate() {
Expand Down
10 changes: 5 additions & 5 deletions datafusion/expr/src/logical_plan/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1530,7 +1530,7 @@ impl LogicalPlan {
// Boilerplate structure to wrap LogicalPlan with something
// that that can be formatted
struct Wrapper<'a>(&'a LogicalPlan);
impl<'a> Display for Wrapper<'a> {
impl Display for Wrapper<'_> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
let with_schema = false;
let mut visitor = IndentVisitor::new(f, with_schema);
Expand Down Expand Up @@ -1573,7 +1573,7 @@ impl LogicalPlan {
// Boilerplate structure to wrap LogicalPlan with something
// that that can be formatted
struct Wrapper<'a>(&'a LogicalPlan);
impl<'a> Display for Wrapper<'a> {
impl Display for Wrapper<'_> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
let with_schema = true;
let mut visitor = IndentVisitor::new(f, with_schema);
Expand All @@ -1593,7 +1593,7 @@ impl LogicalPlan {
// Boilerplate structure to wrap LogicalPlan with something
// that that can be formatted
struct Wrapper<'a>(&'a LogicalPlan);
impl<'a> Display for Wrapper<'a> {
impl Display for Wrapper<'_> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
let mut visitor = PgJsonVisitor::new(f);
visitor.with_schema(true);
Expand Down Expand Up @@ -1639,7 +1639,7 @@ impl LogicalPlan {
// Boilerplate structure to wrap LogicalPlan with something
// that that can be formatted
struct Wrapper<'a>(&'a LogicalPlan);
impl<'a> Display for Wrapper<'a> {
impl Display for Wrapper<'_> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
let mut visitor = GraphvizVisitor::new(f);

Expand Down Expand Up @@ -1690,7 +1690,7 @@ impl LogicalPlan {
// Boilerplate structure to wrap LogicalPlan with something
// that that can be formatted
struct Wrapper<'a>(&'a LogicalPlan);
impl<'a> Display for Wrapper<'a> {
impl Display for Wrapper<'_> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match self.0 {
LogicalPlan::EmptyRelation(_) => write!(f, "EmptyRelation"),
Expand Down
2 changes: 1 addition & 1 deletion datafusion/expr/src/logical_plan/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl Statement {
/// See [crate::LogicalPlan::display] for an example
pub fn display(&self) -> impl fmt::Display + '_ {
struct Wrapper<'a>(&'a Statement);
impl<'a> Display for Wrapper<'a> {
impl Display for Wrapper<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.0 {
Statement::TransactionStart(TransactionStart {
Expand Down
2 changes: 1 addition & 1 deletion datafusion/expr/src/simplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<'a> SimplifyContext<'a> {
}
}

impl<'a> SimplifyInfo for SimplifyContext<'a> {
impl SimplifyInfo for SimplifyContext<'_> {
/// returns true if this Expr has boolean type
fn is_boolean_type(&self, expr: &Expr) -> Result<bool> {
if let Some(schema) = &self.schema {
Expand Down
2 changes: 1 addition & 1 deletion datafusion/expr/src/udwf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ impl WindowUDFImpl for AliasedWindowUDFImpl {
let inner = self.inner.resolve_placeholders(param_values)?;
Ok(if let Some(inner) = inner {
Some(Arc::new(Self {
inner: inner,
inner,
aliases: self.aliases.clone(),
}))
} else {
Expand Down
4 changes: 2 additions & 2 deletions datafusion/functions-aggregate-common/src/merge_arrays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<'a> CustomElement<'a> {
// Overwrite ordering implementation such that
// - `self.ordering` values are used for comparison,
// - When used inside `BinaryHeap` it is a min-heap.
impl<'a> Ord for CustomElement<'a> {
impl Ord for CustomElement<'_> {
fn cmp(&self, other: &Self) -> Ordering {
// Compares according to custom ordering
self.ordering(&self.ordering, &other.ordering)
Expand All @@ -78,7 +78,7 @@ impl<'a> Ord for CustomElement<'a> {
}
}

impl<'a> PartialOrd for CustomElement<'a> {
impl PartialOrd for CustomElement<'_> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions-nested/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,5 @@ impl ExprPlanner for FieldAccessPlanner {
}

fn is_array_agg(agg_func: &datafusion_expr::expr::AggregateFunction) -> bool {
return agg_func.func.name() == "array_agg";
agg_func.func.name() == "array_agg"
}
2 changes: 1 addition & 1 deletion datafusion/functions/src/string/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ pub(crate) enum ColumnarValueRef<'a> {
NonNullableStringViewArray(&'a StringViewArray),
}

impl<'a> ColumnarValueRef<'a> {
impl ColumnarValueRef<'_> {
#[inline]
pub fn is_valid(&self, i: usize) -> bool {
match &self {
Expand Down
2 changes: 1 addition & 1 deletion datafusion/optimizer/src/analyzer/type_coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl<'a> TypeCoercionRewriter<'a> {
}
}

impl<'a> TreeNodeRewriter for TypeCoercionRewriter<'a> {
impl TreeNodeRewriter for TypeCoercionRewriter<'_> {
type Node = Expr;

fn f_up(&mut self, expr: Expr) -> Result<Transformed<Expr>> {
Expand Down
2 changes: 1 addition & 1 deletion datafusion/optimizer/src/join_key_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl<'a> ExprPair<'a> {
}
}

impl<'a> Equivalent<(Expr, Expr)> for ExprPair<'a> {
impl Equivalent<(Expr, Expr)> for ExprPair<'_> {
fn equivalent(&self, other: &(Expr, Expr)) -> bool {
self.0 == &other.0 && self.1 == &other.1
}
Expand Down
2 changes: 1 addition & 1 deletion datafusion/optimizer/src/optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ impl<'a> Rewriter<'a> {
}
}

impl<'a> TreeNodeRewriter for Rewriter<'a> {
impl TreeNodeRewriter for Rewriter<'_> {
type Node = LogicalPlan;

fn f_down(&mut self, node: LogicalPlan) -> Result<Transformed<LogicalPlan>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ enum ConstSimplifyResult {
SimplifyRuntimeError(DataFusionError, Expr),
}

impl<'a> TreeNodeRewriter for ConstEvaluator<'a> {
impl TreeNodeRewriter for ConstEvaluator<'_> {
type Node = Expr;

fn f_down(&mut self, expr: Expr) -> Result<Transformed<Expr>> {
Expand Down Expand Up @@ -705,7 +705,7 @@ impl<'a, S> Simplifier<'a, S> {
}
}

impl<'a, S: SimplifyInfo> TreeNodeRewriter for Simplifier<'a, S> {
impl<S: SimplifyInfo> TreeNodeRewriter for Simplifier<'_, S> {
type Node = Expr;

/// rewrite the expression simplifying any constant expressions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl<'a> GuaranteeRewriter<'a> {
}
}

impl<'a> TreeNodeRewriter for GuaranteeRewriter<'a> {
impl TreeNodeRewriter for GuaranteeRewriter<'_> {
type Node = Expr;

fn f_up(&mut self, expr: Expr) -> Result<Transformed<Expr>> {
Expand Down
2 changes: 1 addition & 1 deletion datafusion/physical-expr-common/src/binary_view_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl ArrowBytesViewSet {
/// This map is used by the special `COUNT DISTINCT` aggregate function to
/// store the distinct values, and by the `GROUP BY` operator to store
/// group values when they are a single string array.
///
pub struct ArrowBytesViewMap<V>
where
V: Debug + PartialEq + Eq + Clone + Copy + Default,
Expand Down
10 changes: 5 additions & 5 deletions datafusion/physical-expr-common/src/sort_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl PhysicalSortExpr {
/// Returns a [`Display`]able list of `PhysicalSortExpr`.
pub fn format_list(input: &[PhysicalSortExpr]) -> impl Display + '_ {
struct DisplayableList<'a>(&'a [PhysicalSortExpr]);
impl<'a> Display for DisplayableList<'a> {
impl Display for DisplayableList<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
let mut first = true;
for sort_expr in self.0 {
Expand Down Expand Up @@ -155,7 +155,7 @@ impl From<PhysicalSortRequirement> for PhysicalSortExpr {
/// If options is `None`, the default sort options `ASC, NULLS LAST` is used.
///
/// The default is picked to be consistent with
/// PostgreSQL: <https://www.postgresql.org/docs/current/queries-order.html>
/// PostgreSQL: <https://www.postgresql.org/docs/current/queries-order.html>
fn from(value: PhysicalSortRequirement) -> Self {
let options = value.options.unwrap_or(SortOptions {
descending: false,
Expand Down Expand Up @@ -207,9 +207,9 @@ impl PhysicalSortRequirement {
/// Returns whether this requirement is equal or more specific than `other`.
pub fn compatible(&self, other: &PhysicalSortRequirement) -> bool {
self.expr.eq(&other.expr)
&& other.options.map_or(true, |other_opts| {
self.options.map_or(false, |opts| opts == other_opts)
})
&& other
.options
.map_or(true, |other_opts| self.options == Some(other_opts))
}

/// Returns [`PhysicalSortRequirement`] that requires the exact
Expand Down
13 changes: 4 additions & 9 deletions datafusion/physical-expr/src/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,10 +539,8 @@ impl AggregateFunctionExpr {
param_values: &Option<ParamValues>,
) -> Result<Option<Arc<Self>>> {
Ok(
if let Some(resolved_args) =
resolve_placeholders_seq(&self.args, param_values)?
{
Some(Arc::new(AggregateFunctionExpr {
resolve_placeholders_seq(&self.args, param_values)?.map(|resolved_args| {
Arc::new(AggregateFunctionExpr {
fun: self.fun.clone(),
args: resolved_args,
data_type: self.data_type.clone(),
Expand All @@ -555,11 +553,8 @@ impl AggregateFunctionExpr {
is_reversed: self.is_reversed,
input_types: self.input_types.clone(),
is_nullable: self.is_nullable,
}))
} else {
// Args do not contain placeholders at all.
None
},
})
}),
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion datafusion/physical-expr/src/expressions/in_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ trait IsEqual: HashValue {
fn is_equal(&self, other: &Self) -> bool;
}

impl<'a, T: IsEqual + ?Sized> IsEqual for &'a T {
impl<T: IsEqual + ?Sized> IsEqual for &T {
fn is_equal(&self, other: &Self) -> bool {
T::is_equal(self, other)
}
Expand Down
8 changes: 3 additions & 5 deletions datafusion/physical-expr/src/expressions/placeholder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub fn resolve_placeholders(
param_values: &'a Option<ParamValues>,
}

impl<'a> TreeNodeRewriter for PlaceholderRewriter<'a> {
impl TreeNodeRewriter for PlaceholderRewriter<'_> {
type Node = Arc<dyn PhysicalExpr>;

fn f_up(&mut self, node: Self::Node) -> Result<Transformed<Self::Node>> {
Expand All @@ -132,7 +132,7 @@ pub fn resolve_placeholders(
if let Some(param_values) = self.param_values {
/* Extract a value and cast to the target type. */
let value = param_values
.get_placeholders_with_values(&id)?
.get_placeholders_with_values(id)?
.cast_to(data_type)?;
Ok(Transformed::yes(lit(value)))
} else {
Expand All @@ -145,9 +145,7 @@ pub fn resolve_placeholders(
}
}

let rewrited = Arc::clone(&expr).rewrite(&mut PlaceholderRewriter {
param_values: &param_values,
})?;
let rewrited = Arc::clone(expr).rewrite(&mut PlaceholderRewriter { param_values })?;

Ok((rewrited.data, rewrited.transformed))
}
Expand Down
2 changes: 1 addition & 1 deletion datafusion/physical-expr/src/utils/guarantee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl LiteralGuarantee {
// for an `AND` conjunction to be true, all terms individually must be true
.fold(GuaranteeBuilder::new(), |builder, expr| {
if let Some(cel) = ColOpLit::try_new(expr) {
return builder.aggregate_conjunct(cel);
builder.aggregate_conjunct(cel)
} else if let Some(inlist) = expr
.as_any()
.downcast_ref::<crate::expressions::InListExpr>()
Expand Down
4 changes: 1 addition & 3 deletions datafusion/physical-expr/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ struct PhysicalExprDAEGBuilder<'a, T, F: Fn(&ExprTreeNode<NodeIndex>) -> Result<
constructor: &'a F,
}

impl<'a, T, F: Fn(&ExprTreeNode<NodeIndex>) -> Result<T>>
PhysicalExprDAEGBuilder<'a, T, F>
{
impl<T, F: Fn(&ExprTreeNode<NodeIndex>) -> Result<T>> PhysicalExprDAEGBuilder<'_, T, F> {
// This method mutates an expression node by transforming it to a physical expression
// and adding it to the graph. The method returns the mutated expression node.
fn mutate(
Expand Down
4 changes: 2 additions & 2 deletions datafusion/physical-expr/src/window/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ pub(super) fn resolve_physical_sort_placeholders(
}
resolved_exprs.push(PhysicalSortExpr {
expr: resolved,
options: expr.options.clone(),
options: expr.options,
});
for j in (i + 1)..exprs.len() {
let e = &exprs[j];
let (resolved, _) = resolve_placeholders(&e.expr, param_values)?;
resolved_exprs.push(PhysicalSortExpr {
expr: resolved,
options: e.options.clone(),
options: e.options,
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion datafusion/physical-expr/src/window/nth_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl BuiltInWindowFunctionExpr for NthValue {
name: self.name.clone(),
expr: resolved,
data_type: self.data_type.clone(),
kind: self.kind.clone(),
kind: self.kind,
ignore_nulls: self.ignore_nulls,
}))
} else {
Expand Down
Loading

0 comments on commit 8c23e1f

Please sign in to comment.