Package org.apache.phoenix.expression.function

Examples of org.apache.phoenix.expression.function.RoundDecimalExpression


        LiteralExpression scale = LiteralExpression.newConstant("3", PDataType.VARCHAR);
        List<Expression> exprs = new ArrayList<Expression>(2);
        exprs.add(bd);
        exprs.add(scale);
        try {
            new RoundDecimalExpression(exprs);
            fail("Evaluation should have failed because only an INTEGER is allowed for second param in a RoundDecimalExpression");
        } catch(IllegalDataException e) {

        }
    }
View Full Code Here


    public static Expression convertToRoundExpressionIfNeeded(PDataType fromDataType, PDataType targetDataType, List<Expression> expressions) throws SQLException {
      Expression firstChildExpr = expressions.get(0);
      if(fromDataType == targetDataType) {
          return firstChildExpr;
      } else if(fromDataType == PDataType.DECIMAL && targetDataType.isCoercibleTo(PDataType.LONG)) {
          return new RoundDecimalExpression(expressions);
      } else if((fromDataType == PDataType.TIMESTAMP || fromDataType == PDataType.UNSIGNED_TIMESTAMP) && targetDataType.isCoercibleTo(PDataType.DATE)) {
          return RoundTimestampExpression.create(expressions);
      } else if(!fromDataType.isCoercibleTo(targetDataType)) {
          throw TypeMismatchException.newException(fromDataType, targetDataType, firstChildExpr.toString());
      }
View Full Code Here

        if(firstChildDataType.isCoercibleTo(PDataType.DATE)) {
            return RoundDateExpression.create(children); // FIXME: remove cast
        } else if (firstChildDataType.isCoercibleTo(PDataType.TIMESTAMP)) {
            return RoundTimestampExpression.create(children); // FIXME: remove cast
        } else if(firstChildDataType.isCoercibleTo(PDataType.DECIMAL)) {
            return new RoundDecimalExpression(children);
        } else {
            throw TypeMismatchException.newException(firstChildDataType, "1");
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.phoenix.expression.function.RoundDecimalExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.