private static List < AbstractExpression > removeNotNullCoveredExpressions ( StmtTableScan tableScan , List < AbstractExpression > coveringExprs , List < AbstractExpression > exprsToCover ) { // Collect all TVEs from NULL-rejecting covering expressions Set < TupleValueExpression > coveringTves = new HashSet <> ( ) ; for ( AbstractExpression coveringExpr : coveringExprs ) { if ( ExpressionUtil . isNullRejectingExpression ( coveringExpr , tableScan . getTableAlias ( ) ) ) { coveringTves . addAll ( ExpressionUtil . getTupleValueExpressions ( coveringExpr ) ) ; } } // For each NOT NULL expression to cover extract the TVE expressions. If all of them are also part // of the covering NULL-rejecting collection then this NOT NULL expression is covered Iterator < AbstractExpression > iter = exprsToCover . iterator ( ) ; while ( iter . hasNext ( ) ) { AbstractExpression filter = iter . next ( ) ; if ( ExpressionType . OPERATOR_NOT == filter . getExpressionType ( ) ) { assert ( filter . getLeft ( ) != null ) ; if ( ExpressionType . OPERATOR_IS_NULL == filter . getLeft ( ) . getExpressionType ( ) ) { assert ( filter . getLeft ( ) . getLeft ( ) != null ) ; List < TupleValueExpression > tves = ExpressionUtil . getTupleValueExpressions ( filter . getLeft ( ) . getLeft ( ) ) ; if ( coveringTves . containsAll ( tves ) ) { iter . remove ( ) ; } } } } return exprsToCover ; }
Remove NOT NULL expressions that are covered by the NULL - rejecting expressions . For example COL IS NOT NULL is covered by the COL > 0 NULL - rejecting comparison expression .