@@ -1511,35 +1511,39 @@ fn build_predicate_expression(
15111511
15121512 // TODO(ets): this is rather parquet specific...still wonder if this should be done
15131513 // at the datasource level
1514- let colidx = column_index_for_expr ( & left, schema)
1515- . or_else ( || column_index_for_expr ( & right, schema) ) ;
1516- if let Some ( colidx) = colidx {
1517- let col_order = column_orderings[ colidx] ;
1518-
1519- // If the ColumnOrder is undefined (as opposed to unknown), we shouldn't be pruning
1520- // since min/max are invalid.
1521- if col_order == ColumnOrdering :: Undefined {
1522- dbg ! ( "Cannot prune because column order is undefined" ) ;
1523- return unhandled_hook. handle ( expr) ;
1524- }
15251514
1526- // left and right should have the same type by now, so only check left
1527- if left. data_type ( schema) . is_ok_and ( |t| t. is_floating ( ) ) {
1528- // By the time we've reached this code, we've narrowed down the possible expressions
1529- // to binary expressions. Of those allowed by `build_statistics_expr`, we only need
1530- // to worry about greater/less than expressions and not equal.
1531- match op {
1532- Operator :: Gt
1533- | Operator :: GtEq
1534- | Operator :: Lt
1535- | Operator :: LtEq
1536- | Operator :: NotEq => {
1537- if col_order != ColumnOrdering :: TotalOrder {
1538- dbg ! ( "Cannot prune floating point column because NaN may be present" ) ;
1539- return unhandled_hook. handle ( expr) ;
1515+ // Sanity check that column orderings match schema
1516+ if column_orderings. len ( ) == schema. fields ( ) . len ( ) {
1517+ let colidx = column_index_for_expr ( & left, schema)
1518+ . or_else ( || column_index_for_expr ( & right, schema) ) ;
1519+ if let Some ( colidx) = colidx {
1520+ let col_order = column_orderings[ colidx] ;
1521+
1522+ // If the ColumnOrder is undefined (as opposed to unknown), we shouldn't be pruning
1523+ // since min/max are invalid.
1524+ if col_order == ColumnOrdering :: Undefined {
1525+ dbg ! ( "Cannot prune because column order is undefined" ) ;
1526+ return unhandled_hook. handle ( expr) ;
1527+ }
1528+
1529+ // left and right should have the same type by now, so only check left
1530+ if left. data_type ( schema) . is_ok_and ( |t| t. is_floating ( ) ) {
1531+ // By the time we've reached this code, we've narrowed down the possible expressions
1532+ // to binary expressions. Of those allowed by `build_statistics_expr`, we only need
1533+ // to worry about greater/less than expressions and not equal.
1534+ match op {
1535+ Operator :: Gt
1536+ | Operator :: GtEq
1537+ | Operator :: Lt
1538+ | Operator :: LtEq
1539+ | Operator :: NotEq => {
1540+ if col_order != ColumnOrdering :: TotalOrder {
1541+ dbg ! ( "Cannot prune floating point column because NaN may be present" ) ;
1542+ return unhandled_hook. handle ( expr) ;
1543+ }
15401544 }
1545+ _ => ( ) ,
15411546 }
1542- _ => ( ) ,
15431547 }
15441548 }
15451549 }
0 commit comments