@@ -389,7 +389,6 @@ impl<'a> PlanIndexStore for &'a dyn MetaStore {
389389#[ derive( Clone ) ]
390390struct SortColumns {
391391 sort_on : Vec < String > ,
392- sort_on_order_col_only : Vec < String > ,
393392 required : bool ,
394393}
395394
@@ -462,18 +461,12 @@ impl PlanRewriter for CollectConstraints {
462461 . map ( |n| n. clone ( ) )
463462 . unique ( )
464463 . collect :: < Vec < _ > > ( ) ,
465- sort_on_order_col_only : order_col_names
466- . iter ( )
467- . map ( |n| n. clone ( ) )
468- . unique ( )
469- . collect :: < Vec < _ > > ( ) ,
470464 required : s. required ,
471465 } )
472466 }
473467 }
474468 None => Some ( SortColumns {
475469 sort_on : order_col_names. clone ( ) ,
476- sort_on_order_col_only : vec ! [ ] ,
477470 required : false ,
478471 } ) ,
479472 }
@@ -515,7 +508,6 @@ impl PlanRewriter for CollectConstraints {
515508 let sort_on = if !sort_on. is_empty ( ) && sort_on. iter ( ) . all ( |c| c. is_some ( ) ) {
516509 Some ( SortColumns {
517510 sort_on : sort_on. into_iter ( ) . map ( |c| c. unwrap ( ) ) . collect ( ) ,
518- sort_on_order_col_only : vec ! [ ] ,
519511 required : false ,
520512 } )
521513 } else {
@@ -563,7 +555,6 @@ impl PlanRewriter for CollectConstraints {
563555 if single_value_filter_columns ( predicate, & mut sort_on) {
564556 if !sort_on. is_empty ( ) {
565557 let sort_on = Some ( SortColumns {
566- sort_on_order_col_only : vec ! [ ] ,
567558 sort_on : sort_on
568559 . into_iter ( )
569560 . map ( |c| c. name . to_string ( ) )
@@ -600,7 +591,6 @@ impl PlanRewriter for CollectConstraints {
600591 }
601592 Some ( ConstraintsContext {
602593 sort_on : Some ( SortColumns {
603- sort_on_order_col_only : vec ! [ ] ,
604594 sort_on : join_on. iter ( ) . map ( |( l, _) | l. name . clone ( ) ) . collect ( ) ,
605595 required : true ,
606596 } ) ,
@@ -622,7 +612,6 @@ impl PlanRewriter for CollectConstraints {
622612 }
623613 Some ( ConstraintsContext {
624614 sort_on : Some ( SortColumns {
625- sort_on_order_col_only : vec ! [ ] ,
626615 sort_on : join_on. iter ( ) . map ( |( _, r) | r. name . clone ( ) ) . collect ( ) ,
627616 required : true ,
628617 } ) ,
@@ -1071,10 +1060,6 @@ async fn pick_index(
10711060 indices : Vec < IdRow < Index > > ,
10721061) -> Result < IndexCandidate , DataFusionError > {
10731062 let sort_on = c. sort_on . as_ref ( ) . map ( |sc| ( & sc. sort_on , sc. required ) ) ;
1074- let sort_on_order_col_only = c
1075- . sort_on
1076- . as_ref ( )
1077- . map ( |sc| ( & sc. sort_on_order_col_only , sc. required ) ) ;
10781063
10791064 let aggr_index_allowed = check_aggregates_expr ( & table, & c. aggregates ) ;
10801065
@@ -1189,24 +1174,17 @@ async fn pick_index(
11891174 ) ) ) ;
11901175 ( err, None , sort_on)
11911176 } else {
1192- let filter_columns_updated = match sort_on_order_col_only {
1193- Some ( _) => HashSet :: new ( ) ,
1194- _ => filter_columns,
1195- } ;
11961177 let optimal = optimal_index_by_score (
11971178 // Skipping default index
11981179 indices. iter ( ) . skip ( 1 ) ,
11991180 & projection_columns,
1200- & filter_columns_updated ,
1181+ & filter_columns ,
12011182 ) ;
12021183 let index = optimal. unwrap_or ( default_index) ;
12031184 (
12041185 Ok ( index) ,
12051186 index. get_row ( ) . multi_index_id ( ) . map ( |_| index) ,
1206- match sort_on_order_col_only {
1207- Some ( ( columns, flag) ) if !columns. is_empty ( ) => Some ( ( columns, flag) ) ,
1208- _ => None ,
1209- } ,
1187+ None ,
12101188 )
12111189 }
12121190 }
@@ -1262,7 +1240,7 @@ fn optimal_index_by_score<'a, T: Iterator<Item = &'a IdRow<Index>>>(
12621240 projection_columns : & Vec < Column > ,
12631241 filter_columns : & HashSet < logical_plan:: Column > ,
12641242) -> Option < & ' a IdRow < Index > > {
1265- #[ derive( PartialEq , Eq , Clone ) ]
1243+ #[ derive( PartialEq , Eq , Clone , Debug ) ]
12661244 struct Score {
12671245 index_type : IndexType ,
12681246 index_size : u64 ,
@@ -1330,6 +1308,12 @@ fn optimal_index_by_score<'a, T: Iterator<Item = &'a IdRow<Index>>>(
13301308 None
13311309 } ;
13321310
1311+ println ! (
1312+ "Index score is {:?} {:?}" ,
1313+ i. get_row( ) . get_name( ) ,
1314+ index_score
1315+ ) ;
1316+
13331317 let res = Some ( i) . zip ( index_score) ;
13341318 res
13351319 } )
0 commit comments