Skip to content

Commit e1e7b86

Browse files
Address clippy warnings (#1553)
* Fix 'new_without_default' clippy warnings * Fix 'from_over_into' clippy warnings * Push 'allow(module_inception)' down from lib.rs * Fix 'complex_type' clippy warning with type alias * Remove unused yet allowed clippy warnings * Fix 'new_without_default' clippy warnings for tests
1 parent 06d147a commit e1e7b86

26 files changed

Lines changed: 125 additions & 36 deletions

datafusion/src/catalog/catalog.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ impl MemoryCatalogList {
5959
}
6060
}
6161

62+
impl Default for MemoryCatalogList {
63+
fn default() -> Self {
64+
Self::new()
65+
}
66+
}
67+
6268
impl CatalogList for MemoryCatalogList {
6369
fn as_any(&self) -> &dyn Any {
6470
self
@@ -84,6 +90,12 @@ impl CatalogList for MemoryCatalogList {
8490
}
8591
}
8692

93+
impl Default for MemoryCatalogProvider {
94+
fn default() -> Self {
95+
Self::new()
96+
}
97+
}
98+
8799
/// Represents a catalog, comprising a number of named schemas.
88100
pub trait CatalogProvider: Sync + Send {
89101
/// Returns the catalog provider as [`Any`](std::any::Any)

datafusion/src/catalog/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
//! This module contains interfaces and default implementations
1919
//! of table namespacing concepts, including catalogs and schemas.
2020
21+
#![allow(clippy::module_inception)]
2122
pub mod catalog;
2223
pub mod information_schema;
2324
pub mod schema;

datafusion/src/catalog/schema.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ impl MemorySchemaProvider {
7979
}
8080
}
8181

82+
impl Default for MemorySchemaProvider {
83+
fn default() -> Self {
84+
Self::new()
85+
}
86+
}
87+
8288
impl SchemaProvider for MemorySchemaProvider {
8389
fn as_any(&self) -> &dyn Any {
8490
self

datafusion/src/datasource/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
//! DataFusion data sources
1919
20+
#![allow(clippy::module_inception)]
2021
pub mod datasource;
2122
pub mod empty;
2223
pub mod file_format;

datafusion/src/datasource/object_store/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ impl fmt::Debug for ObjectStoreRegistry {
186186
}
187187
}
188188

189+
impl Default for ObjectStoreRegistry {
190+
fn default() -> Self {
191+
Self::new()
192+
}
193+
}
194+
189195
impl ObjectStoreRegistry {
190196
/// Create the registry that object stores can registered into.
191197
/// ['LocalFileSystem'] store is registered in by default to support read local files natively.

datafusion/src/execution/context.rs

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ pub struct ExecutionContext {
141141
pub state: Arc<Mutex<ExecutionContextState>>,
142142
}
143143

144+
impl Default for ExecutionContext {
145+
fn default() -> Self {
146+
Self::new()
147+
}
148+
}
149+
144150
impl ExecutionContext {
145151
/// Creates a new execution context using a default configuration.
146152
pub fn new() -> Self {
@@ -1049,6 +1055,27 @@ pub struct ExecutionProps {
10491055
pub(crate) query_execution_start_time: DateTime<Utc>,
10501056
}
10511057

1058+
impl Default for ExecutionProps {
1059+
fn default() -> Self {
1060+
Self::new()
1061+
}
1062+
}
1063+
1064+
impl ExecutionProps {
1065+
/// Creates a new execution props
1066+
pub fn new() -> Self {
1067+
ExecutionProps {
1068+
query_execution_start_time: chrono::Utc::now(),
1069+
}
1070+
}
1071+
1072+
/// Marks the execution of query started timestamp
1073+
pub fn start_execution(&mut self) -> &Self {
1074+
self.query_execution_start_time = chrono::Utc::now();
1075+
&*self
1076+
}
1077+
}
1078+
10521079
/// Execution context for registering data sources and executing queries
10531080
#[derive(Clone)]
10541081
pub struct ExecutionContextState {
@@ -1068,18 +1095,9 @@ pub struct ExecutionContextState {
10681095
pub object_store_registry: Arc<ObjectStoreRegistry>,
10691096
}
10701097

1071-
impl ExecutionProps {
1072-
/// Creates a new execution props
1073-
pub fn new() -> Self {
1074-
ExecutionProps {
1075-
query_execution_start_time: chrono::Utc::now(),
1076-
}
1077-
}
1078-
1079-
/// Marks the execution of query started timestamp
1080-
pub fn start_execution(&mut self) -> &Self {
1081-
self.query_execution_start_time = chrono::Utc::now();
1082-
&*self
1098+
impl Default for ExecutionContextState {
1099+
fn default() -> Self {
1100+
Self::new()
10831101
}
10841102
}
10851103

datafusion/src/execution/options.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ pub struct CsvReadOptions<'a> {
4646
pub file_extension: &'a str,
4747
}
4848

49+
impl<'a> Default for CsvReadOptions<'a> {
50+
fn default() -> Self {
51+
Self::new()
52+
}
53+
}
54+
4955
impl<'a> CsvReadOptions<'a> {
5056
/// Create a CSV read option with default presets
5157
pub fn new() -> Self {

datafusion/src/lib.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,6 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717
#![warn(missing_docs, clippy::needless_borrow)]
18-
// Clippy lints, some should be disabled incrementally
19-
#![allow(
20-
clippy::float_cmp,
21-
clippy::from_over_into,
22-
clippy::module_inception,
23-
clippy::new_without_default,
24-
clippy::type_complexity,
25-
clippy::upper_case_acronyms
26-
)]
2718

2819
//! [DataFusion](https://github.com/apache/arrow-datafusion)
2920
//! is an extensible query execution framework that uses

datafusion/src/logical_plan/dfschema.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,12 @@ impl DFSchema {
297297
}
298298
}
299299

300-
impl Into<Schema> for DFSchema {
301-
/// Convert a schema into a DFSchema
302-
fn into(self) -> Schema {
300+
impl From<DFSchema> for Schema {
301+
/// Convert DFSchema into a Schema
302+
fn from(df_schema: DFSchema) -> Self {
303303
Schema::new(
304-
self.fields
304+
df_schema
305+
.fields
305306
.into_iter()
306307
.map(|f| {
307308
if f.qualifier().is_some() {
@@ -319,10 +320,10 @@ impl Into<Schema> for DFSchema {
319320
}
320321
}
321322

322-
impl Into<Schema> for &DFSchema {
323-
/// Convert a schema into a DFSchema
324-
fn into(self) -> Schema {
325-
Schema::new(self.fields.iter().map(|f| f.field.clone()).collect())
323+
impl From<&DFSchema> for Schema {
324+
/// Convert DFSchema reference into a Schema
325+
fn from(df_schema: &DFSchema) -> Self {
326+
Schema::new(df_schema.fields.iter().map(|f| f.field.clone()).collect())
326327
}
327328
}
328329

@@ -340,9 +341,9 @@ impl TryFrom<Schema> for DFSchema {
340341
}
341342
}
342343

343-
impl Into<SchemaRef> for DFSchema {
344-
fn into(self) -> SchemaRef {
345-
SchemaRef::new(self.into())
344+
impl From<DFSchema> for SchemaRef {
345+
fn from(df_schema: DFSchema) -> Self {
346+
SchemaRef::new(df_schema.into())
346347
}
347348
}
348349

datafusion/src/optimizer/common_subexpr_eliminate.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ impl OptimizerRule for CommonSubexprEliminate {
6969
}
7070
}
7171

72+
impl Default for CommonSubexprEliminate {
73+
fn default() -> Self {
74+
Self::new()
75+
}
76+
}
77+
7278
impl CommonSubexprEliminate {
7379
#[allow(missing_docs)]
7480
pub fn new() -> Self {

0 commit comments

Comments
 (0)