datafusion icon indicating copy to clipboard operation
datafusion copied to clipboard

Configure `cargo fmt` for consistent formatting of imports in `datafusion-common` crate

Open andygrove opened this issue 3 years ago • 2 comments

Which issue does this PR close?

Part of https://github.com/apache/arrow-datafusion/issues/3591

Rationale for this change

Our imports are very inconsistent and are not currently formatted by cargo fmt other than reordering within groups.

I would like to add a rustfmt.toml with these settings:

imports_granularity="Crate"
group_imports="StdExternalCrate"

Here is an example of imports formatted with these settings, using the command cargo +nightly fmt:

use std::{
    collections::{HashMap, HashSet},
    convert::TryFrom,
    fmt::{Display, Formatter},
    sync::Arc,
};

use arrow::{
    compute::can_cast_types,
    datatypes::{DataType, Field, Schema, SchemaRef},
};

use crate::{
    error::{DataFusionError, Result, SchemaError},
    field_not_found, Column,
};

What changes are included in this PR?

Apply this formatting just to the common crate as an example.

Are there any user-facing changes?

No

andygrove avatar Sep 22 '22 21:09 andygrove

Codecov Report

Merging #3592 (37c2505) into master (add10a6) will increase coverage by 0.00%. The diff coverage is 71.60%.

@@           Coverage Diff           @@
##           master    #3592   +/-   ##
=======================================
  Coverage   86.06%   86.06%           
=======================================
  Files         300      300           
  Lines       56328    56302   -26     
=======================================
- Hits        48476    48459   -17     
+ Misses       7852     7843    -9     
Impacted Files Coverage Δ
datafusion/common/src/from_slice.rs 100.00% <ø> (ø)
datafusion/common/src/lib.rs 0.00% <0.00%> (ø)
datafusion/common/src/pyarrow.rs 0.00% <ø> (ø)
datafusion/common/src/dfschema.rs 93.87% <45.45%> (+0.24%) :arrow_up:
datafusion/common/src/error.rs 78.65% <50.00%> (ø)
datafusion/common/src/scalar.rs 85.44% <77.27%> (+0.19%) :arrow_up:
datafusion/common/src/column.rs 95.12% <100.00%> (ø)
datafusion/core/src/physical_plan/metrics/value.rs 86.93% <0.00%> (-0.51%) :arrow_down:
datafusion/expr/src/logical_plan/plan.rs 77.42% <0.00%> (+0.32%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov-commenter avatar Sep 22 '22 22:09 codecov-commenter

clippy failures are unrelated - probably due to new rust version

andygrove avatar Sep 22 '22 22:09 andygrove