Github user twdsilva commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/417#discussion_r244065508
  
    --- Diff: 
phoenix-core/src/main/java/org/apache/phoenix/util/ExpressionUtil.java ---
    @@ -68,4 +76,144 @@ public static boolean isPkPositionChanging(TableRef 
tableRef, List<Expression> p
             return false;
         }
     
    +    /**
    +     * check the whereExpression to see if the columnExpression is 
constant.
    +     * eg. for "where a =3 and b > 9", a is constant,but b is not.
    +     * @param columnExpression
    +     * @param whereExpression
    +     * @return
    +     */
    +    public static boolean isColumnExpressionConstant(ColumnExpression 
columnExpression, Expression whereExpression) {
    +        if(whereExpression == null) {
    +            return false;
    +        }
    +        IsColumnConstantExpressionVisitor 
isColumnConstantExpressionVisitor =
    +                new IsColumnConstantExpressionVisitor(columnExpression);
    +        whereExpression.accept(isColumnConstantExpressionVisitor);
    +        return isColumnConstantExpressionVisitor.isConstant();
    +    }
    +
    +    private static class IsColumnConstantExpressionVisitor extends 
StatelessTraverseNoExpressionVisitor<Void> {
    +        private final Expression columnExpression ;
    +        private Expression firstRhsConstantExpression = null;
    +        private int rhsConstantCount = 0;
    +        private boolean isNullExpressionVisited = false;
    +
    +        public IsColumnConstantExpressionVisitor(Expression 
columnExpression) {
    +            this.columnExpression = columnExpression;
    +        }
    +        /**
    +         * only conside and,for "where a = 3 or b = 9", neither a or b is 
constant.
    --- End diff --
    
    nit: only consider


---

Reply via email to