File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed
native/core/src/execution Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,14 @@ impl CopyExec {
91
91
mode,
92
92
}
93
93
}
94
+
95
+ pub fn input ( & self ) -> & Arc < dyn ExecutionPlan > {
96
+ & self . input
97
+ }
98
+
99
+ pub fn mode ( & self ) -> & CopyMode {
100
+ & self . mode
101
+ }
94
102
}
95
103
96
104
impl DisplayAs for CopyExec {
Original file line number Diff line number Diff line change @@ -2610,10 +2610,23 @@ impl From<ExpressionError> for DataFusionError {
2610
2610
/// modification. This is used to determine if we need to copy the input batch to avoid
2611
2611
/// data corruption from reusing the input batch.
2612
2612
fn can_reuse_input_batch ( op : & Arc < dyn ExecutionPlan > ) -> bool {
2613
- if op. as_any ( ) . is :: < ProjectionExec > ( ) || op. as_any ( ) . is :: < LocalLimitExec > ( ) {
2614
- can_reuse_input_batch ( op. children ( ) [ 0 ] )
2613
+ if op. as_any ( ) . is :: < ScanExec > ( ) {
2614
+ // JVM side can return arrow buffers to the pool
2615
+ // Also, native_comet scan reuses mutable buffers
2616
+ true
2617
+ } else if op. as_any ( ) . is :: < CopyExec > ( ) {
2618
+ let copy_exec = op. as_any ( ) . downcast_ref :: < CopyExec > ( ) . unwrap ( ) ;
2619
+ copy_exec. mode ( ) == & CopyMode :: UnpackOrClone && can_reuse_input_batch ( copy_exec. input ( ) )
2620
+ } else if op. as_any ( ) . is :: < CometFilterExec > ( ) {
2621
+ // CometFilterExec guarantees that all arrays have been copied
2622
+ false
2615
2623
} else {
2616
- op. as_any ( ) . is :: < ScanExec > ( )
2624
+ for child in op. children ( ) {
2625
+ if can_reuse_input_batch ( child) {
2626
+ return true ;
2627
+ }
2628
+ }
2629
+ false
2617
2630
}
2618
2631
}
2619
2632
You can’t perform that action at this time.
0 commit comments