Skip to content

Commit 377c0fc

Browse files
authored
chore: enforce lint rule clippy::needless_pass_by_value to datafusion-datasource-avro (#18641)
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> - Closes #18612. ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> - Enforce lint rule `clippy::needless_pass_by_value` to `datafusion-datasource-avro`. ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. --> Signed-off-by: Alan Tang <[email protected]>
1 parent e42a0b6 commit 377c0fc

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

datafusion/datasource-avro/src/avro_to_arrow/reader.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl ReaderBuilder {
113113
None => Arc::new(super::read_avro_schema_from_reader(&mut source)?),
114114
};
115115
source.rewind()?;
116-
Reader::try_new(source, schema, self.batch_size, self.projection)
116+
Reader::try_new(source, &schema, self.batch_size, self.projection.as_ref())
117117
}
118118
}
119119

@@ -135,12 +135,12 @@ impl<R: Read> Reader<'_, R> {
135135
/// useful if plucking values from a struct, e.g. getting `a.b.c.e` from `a.b.c.{d, e}`.
136136
pub fn try_new(
137137
reader: R,
138-
schema: SchemaRef,
138+
schema: &SchemaRef,
139139
batch_size: usize,
140-
projection: Option<Vec<String>>,
140+
projection: Option<&Vec<String>>,
141141
) -> Result<Self> {
142142
let projected_schema = projection.as_ref().filter(|p| !p.is_empty()).map_or_else(
143-
|| Arc::clone(&schema),
143+
|| Arc::clone(schema),
144144
|proj| {
145145
Arc::new(arrow::datatypes::Schema::new(
146146
proj.iter()

datafusion/datasource-avro/src/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
// Make sure fast / cheap clones on Arc are explicit:
2424
// https://github.com/apache/datafusion/issues/11143
2525
#![cfg_attr(not(test), deny(clippy::clone_on_ref_ptr))]
26+
#![deny(clippy::needless_pass_by_value)]
27+
#![cfg_attr(test, allow(clippy::needless_pass_by_value))]
2628

2729
//! An [Avro](https://avro.apache.org/) based [`FileSource`](datafusion_datasource::file::FileSource) implementation and related functionality.
2830

datafusion/datasource-avro/src/source.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ impl AvroSource {
6161
fn open<R: std::io::Read>(&self, reader: R) -> Result<AvroReader<'static, R>> {
6262
AvroReader::try_new(
6363
reader,
64-
Arc::clone(self.table_schema.file_schema()),
64+
&Arc::clone(self.table_schema.file_schema()),
6565
self.batch_size.expect("Batch size must set before open"),
66-
self.projection.clone(),
66+
self.projection.clone().as_ref(),
6767
)
6868
}
6969
}

0 commit comments

Comments
 (0)