Skip to content

Commit

Permalink
Enable clone_on_ref_ptr clippy lint on sql (#11380)
Browse files Browse the repository at this point in the history
  • Loading branch information
lewiszlw authored Jul 11, 2024
1 parent 2413155 commit ed65c11
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion datafusion/sql/examples/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ fn create_table_source(fields: Vec<Field>) -> Arc<dyn TableSource> {
impl ContextProvider for MyContextProvider {
fn get_table_source(&self, name: TableReference) -> Result<Arc<dyn TableSource>> {
match self.tables.get(name.table()) {
Some(table) => Ok(table.clone()),
Some(table) => Ok(Arc::clone(table)),
_ => plan_err!("Table not found: {}", name.table()),
}
}
Expand Down
2 changes: 1 addition & 1 deletion datafusion/sql/src/cte.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
// as the input to the recursive term
let work_table_plan = LogicalPlanBuilder::scan(
cte_name.to_string(),
work_table_source.clone(),
Arc::clone(&work_table_source),
None,
)?
.build()?;
Expand Down
2 changes: 1 addition & 1 deletion datafusion/sql/src/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ mod tests {
impl ContextProvider for TestContextProvider {
fn get_table_source(&self, name: TableReference) -> Result<Arc<dyn TableSource>> {
match self.tables.get(name.table()) {
Some(table) => Ok(table.clone()),
Some(table) => Ok(Arc::clone(table)),
_ => plan_err!("Table not found: {}", name.table()),
}
}
Expand Down
2 changes: 2 additions & 0 deletions datafusion/sql/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// Make cheap clones clear: https://github.com/apache/datafusion/issues/11143
#![deny(clippy::clone_on_ref_ptr)]

//! This module provides:
//!
Expand Down
4 changes: 2 additions & 2 deletions datafusion/sql/src/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -870,12 +870,12 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
self.context_provider.get_table_source(table_ref.clone())?;
let plan =
LogicalPlanBuilder::scan(table_name, table_source, None)?.build()?;
let input_schema = plan.schema().clone();
let input_schema = Arc::clone(plan.schema());
(plan, input_schema, Some(table_ref))
}
CopyToSource::Query(query) => {
let plan = self.query_to_plan(query, &mut PlannerContext::new())?;
let input_schema = plan.schema().clone();
let input_schema = Arc::clone(plan.schema());
(plan, input_schema, None)
}
};
Expand Down
2 changes: 1 addition & 1 deletion datafusion/sql/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,6 @@ impl TableSource for EmptyTable {
}

fn schema(&self) -> SchemaRef {
self.table_schema.clone()
Arc::clone(&self.table_schema)
}
}

0 comments on commit ed65c11

Please sign in to comment.