File tree Expand file tree Collapse file tree
core/src/execution/context
physical-plan/src/joins/hash_join
substrait/src/logical_plan/consumer/rel Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -950,13 +950,13 @@ impl SessionContext {
950950 match ( or_replace, view) {
951951 ( true , Ok ( _) ) => {
952952 self . deregister_table ( name. clone ( ) ) ?;
953- let input = Self :: apply_type_coercion ( input . as_ref ( ) . clone ( ) ) ?;
953+ let input = Self :: apply_type_coercion ( Arc :: unwrap_or_clone ( input ) ) ?;
954954 let table = Arc :: new ( ViewTable :: new ( input, definition) ) ;
955955 self . register_table ( name, table) ?;
956956 self . return_empty_dataframe ( )
957957 }
958958 ( _, Err ( _) ) => {
959- let input = Self :: apply_type_coercion ( input . as_ref ( ) . clone ( ) ) ?;
959+ let input = Self :: apply_type_coercion ( Arc :: unwrap_or_clone ( input ) ) ?;
960960 let table = Arc :: new ( ViewTable :: new ( input, definition) ) ;
961961 self . register_table ( name, table) ?;
962962 self . return_empty_dataframe ( )
Original file line number Diff line number Diff line change @@ -165,7 +165,7 @@ impl FileFormat for ArrowFormat {
165165 }
166166 GetResultPayload :: Stream ( stream) => infer_stream_schema ( stream) . await ?,
167167 } ;
168- schemas. push ( schema . as_ref ( ) . clone ( ) ) ;
168+ schemas. push ( Arc :: unwrap_or_clone ( schema ) ) ;
169169 }
170170 let merged_schema = Schema :: try_merge ( schemas) ?;
171171 Ok ( Arc :: new ( merged_schema) )
Original file line number Diff line number Diff line change @@ -3625,7 +3625,6 @@ impl Aggregate {
36253625 ///
36263626 /// This method should only be called when you are absolutely sure that the schema being
36273627 /// provided is correct for the aggregate. If in doubt, call [try_new](Self::try_new) instead.
3628- #[ expect( clippy:: needless_pass_by_value) ]
36293628 pub fn try_new_with_schema (
36303629 input : Arc < LogicalPlan > ,
36313630 group_expr : Vec < Expr > ,
@@ -3651,7 +3650,7 @@ impl Aggregate {
36513650
36523651 let aggregate_func_dependencies =
36533652 calc_func_dependencies_for_aggregate ( & group_expr, & input, & schema) ?;
3654- let new_schema = schema . as_ref ( ) . clone ( ) ;
3653+ let new_schema = Arc :: unwrap_or_clone ( schema ) ;
36553654 let schema = Arc :: new (
36563655 new_schema. with_functional_dependencies ( aggregate_func_dependencies) ?,
36573656 ) ;
Original file line number Diff line number Diff line change @@ -391,7 +391,7 @@ impl ScalarUDFImpl for ForeignScalarUDF {
391391 . map ( WrappedSchema )
392392 . collect :: < RVec < _ > > ( ) ;
393393
394- let return_field = return_field . as_ref ( ) . clone ( ) ;
394+ let return_field = Arc :: unwrap_or_clone ( return_field ) ;
395395 let return_field = WrappedSchema ( FFI_ArrowSchema :: try_from ( return_field) ?) ;
396396 let config_options = config_options. as_ref ( ) . into ( ) ;
397397
Original file line number Diff line number Diff line change @@ -247,9 +247,7 @@ fn extract_from_plan(
247247 Some ( plan) => Ok ( plan) ,
248248 // No extractions for this input — recover the LogicalPlan
249249 // without cloning (refcount is 1 since build returned None).
250- None => {
251- Ok ( Arc :: try_unwrap ( input_arc) . unwrap_or_else ( |arc| ( * arc) . clone ( ) ) )
252- }
250+ None => Ok ( Arc :: unwrap_or_clone ( input_arc) ) ,
253251 }
254252 } )
255253 . collect :: < Result < Vec < _ > > > ( ) ?;
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ impl OptimizerRule for ReplaceDistinctWithAggregate {
109109 . enumerate ( )
110110 . all ( |( idx, f_idx) | idx == * f_idx)
111111 {
112- return Ok ( Transformed :: yes ( input . as_ref ( ) . clone ( ) ) ) ;
112+ return Ok ( Transformed :: yes ( Arc :: unwrap_or_clone ( input ) ) ) ;
113113 }
114114 }
115115
Original file line number Diff line number Diff line change @@ -1450,8 +1450,8 @@ impl ExecutionPlan for HashJoinExec {
14501450 let right_stats = self . right . partition_statistics ( Some ( partition) ) ?;
14511451
14521452 estimate_join_statistics (
1453- ( * left_stats) . clone ( ) ,
1454- ( * right_stats) . clone ( ) ,
1453+ Arc :: unwrap_or_clone ( left_stats) ,
1454+ Arc :: unwrap_or_clone ( right_stats) ,
14551455 & self . on ,
14561456 & self . join_type ,
14571457 & self . join_schema ,
@@ -1465,8 +1465,8 @@ impl ExecutionPlan for HashJoinExec {
14651465 let right_stats = self . right . partition_statistics ( Some ( partition) ) ?;
14661466
14671467 estimate_join_statistics (
1468- ( * left_stats) . clone ( ) ,
1469- ( * right_stats) . clone ( ) ,
1468+ Arc :: unwrap_or_clone ( left_stats) ,
1469+ Arc :: unwrap_or_clone ( right_stats) ,
14701470 & self . on ,
14711471 & self . join_type ,
14721472 & self . join_schema ,
@@ -1482,8 +1482,8 @@ impl ExecutionPlan for HashJoinExec {
14821482 let left_stats = self . left . partition_statistics ( None ) ?;
14831483 let right_stats = self . right . partition_statistics ( None ) ?;
14841484 estimate_join_statistics (
1485- ( * left_stats) . clone ( ) ,
1486- ( * right_stats) . clone ( ) ,
1485+ Arc :: unwrap_or_clone ( left_stats) ,
1486+ Arc :: unwrap_or_clone ( right_stats) ,
14871487 & self . on ,
14881488 & self . join_type ,
14891489 & self . join_schema ,
Original file line number Diff line number Diff line change @@ -389,7 +389,7 @@ fn optimize_subquery_sort(
389389 LogicalPlan :: Sort ( s) => {
390390 if !has_limit {
391391 has_limit = false ;
392- return Ok ( Transformed :: yes ( s. input . as_ref ( ) . clone ( ) ) ) ;
392+ return Ok ( Transformed :: yes ( Arc :: unwrap_or_clone ( s. input ) ) ) ;
393393 }
394394 Ok ( Transformed :: no ( LogicalPlan :: Sort ( s) ) )
395395 }
Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ pub async fn from_aggregate_rel(
106106 not_impl_err ! ( "Aggregate without aggregate function is not supported" )
107107 }
108108 } ;
109- aggr_exprs. push ( agg_func?. as_ref ( ) . clone ( ) ) ;
109+ aggr_exprs. push ( std :: sync :: Arc :: unwrap_or_clone ( agg_func?) ) ;
110110 }
111111
112112 // Ensure that all expressions have a unique name
You can’t perform that action at this time.
0 commit comments