@@ -185,7 +185,7 @@ impl ExecutionPlan for SortExec {
185
185
}
186
186
187
187
fn statistics ( & self ) -> Result < Statistics > {
188
- todo ! ( )
188
+ Statistics :: with_fetch ( self . input . statistics ( ) ? , self . schema ( ) , self . fetch , 0 , 1 )
189
189
}
190
190
}
191
191
@@ -1393,9 +1393,9 @@ mod fuzztest {
1393
1393
record_batch:: RecordBatch ,
1394
1394
} ;
1395
1395
use datafusion:: {
1396
- common:: Result ,
1396
+ common:: { stats :: Precision , Result } ,
1397
1397
physical_expr:: { expressions:: Column , PhysicalSortExpr } ,
1398
- physical_plan:: memory:: MemoryExec ,
1398
+ physical_plan:: { memory:: MemoryExec , ExecutionPlan } ,
1399
1399
prelude:: { SessionConfig , SessionContext } ,
1400
1400
} ;
1401
1401
@@ -1460,8 +1460,9 @@ mod fuzztest {
1460
1460
None ,
1461
1461
) ?) ;
1462
1462
let sort = Arc :: new ( SortExec :: new ( input, sort_exprs. clone ( ) , None ) ) ;
1463
- let output = datafusion:: physical_plan:: collect ( sort, task_ctx. clone ( ) ) . await ?;
1463
+ let output = datafusion:: physical_plan:: collect ( sort. clone ( ) , task_ctx. clone ( ) ) . await ?;
1464
1464
let a = concat_batches ( & schema, & output) ?;
1465
+ let a_row_count = sort. clone ( ) . statistics ( ) ?. num_rows ;
1465
1466
1466
1467
let input = Arc :: new ( MemoryExec :: try_new (
1467
1468
& [ batches. clone ( ) ] ,
@@ -1472,10 +1473,13 @@ mod fuzztest {
1472
1473
sort_exprs. clone ( ) ,
1473
1474
input,
1474
1475
) ) ;
1475
- let output = datafusion:: physical_plan:: collect ( sort, task_ctx. clone ( ) ) . await ?;
1476
+ let output = datafusion:: physical_plan:: collect ( sort. clone ( ) , task_ctx. clone ( ) ) . await ?;
1476
1477
let b = concat_batches ( & schema, & output) ?;
1478
+ let b_row_count = sort. clone ( ) . statistics ( ) ?. num_rows ;
1477
1479
1478
1480
assert_eq ! ( a. num_rows( ) , b. num_rows( ) ) ;
1481
+ assert_eq ! ( a_row_count, b_row_count) ;
1482
+ assert_eq ! ( a_row_count, Precision :: Exact ( n) ) ;
1479
1483
assert ! ( a == b) ;
1480
1484
Ok ( ( ) )
1481
1485
}
0 commit comments