Search in sources :

Example 1 with Modulo

use of net.sf.jsqlparser.expression.operators.arithmetic.Modulo in project herddb by diennea.

the class SQLParserExpressionCompiler method compileBinaryExpression.

private static CompiledSQLExpression compileBinaryExpression(BinaryExpression expression, OpSchema tableSchema) {
    CompiledSQLExpression left = compileExpression(expression.getLeftExpression(), tableSchema);
    CompiledSQLExpression right = compileExpression(expression.getRightExpression(), tableSchema);
    if (expression instanceof EqualsTo) {
        EqualsTo eq = (EqualsTo) expression;
        checkSupported(eq.getOldOracleJoinSyntax() == EqualsTo.NO_ORACLE_JOIN);
        checkSupported(eq.getOraclePriorPosition() == EqualsTo.NO_ORACLE_PRIOR);
        return new CompiledEqualsExpression(left, right);
    } else if (expression instanceof AndExpression) {
        return new CompiledAndExpression(left, right);
    } else if (expression instanceof OrExpression) {
        return new CompiledOrExpression(left, right);
    } else if (expression instanceof GreaterThan) {
        return new CompiledGreaterThanExpression(left, right);
    } else if (expression instanceof GreaterThanEquals) {
        return new CompiledGreaterThanEqualsExpression(left, right);
    } else if (expression instanceof MinorThan) {
        return new CompiledMinorThanExpression(left, right);
    } else if (expression instanceof MinorThanEquals) {
        return new CompiledMinorThanEqualsExpression(left, right);
    } else if (expression instanceof Addition) {
        return new CompiledAddExpression(left, right);
    } else if (expression instanceof Division) {
        return new CompiledDivideExpression(left, right);
    } else if (expression instanceof Multiplication) {
        return new CompiledMultiplyExpression(left, right);
    } else if (expression instanceof LikeExpression) {
        LikeExpression eq = (LikeExpression) expression;
        if (eq.isCaseInsensitive()) {
            // this is not supported by Calcite, do not support it with jSQLParser
            throw new StatementExecutionException("ILIKE is not supported");
        }
        CompiledSQLExpression res;
        if (eq.getEscape() != null) {
            CompiledSQLExpression escape = new ConstantExpression(eq.getEscape(), ColumnTypes.NOTNULL_STRING);
            res = new CompiledLikeExpression(left, right, escape);
        } else {
            res = new CompiledLikeExpression(left, right);
        }
        if (eq.isNot()) {
            res = new CompiledNotExpression(res);
        }
        return res;
    } else if (expression instanceof Modulo) {
        return new CompiledModuloExpression(left, right);
    } else if (expression instanceof Subtraction) {
        return new CompiledSubtractExpression(left, right);
    } else if (expression instanceof NotEqualsTo) {
        NotEqualsTo eq = (NotEqualsTo) expression;
        checkSupported(eq.getOldOracleJoinSyntax() == EqualsTo.NO_ORACLE_JOIN);
        checkSupported(eq.getOraclePriorPosition() == EqualsTo.NO_ORACLE_PRIOR);
        return new CompiledNotEqualsExpression(left, right);
    } else {
        throw new StatementExecutionException("not implemented expression type " + expression.getClass() + ": " + expression);
    }
}
Also used : MinorThanEquals(net.sf.jsqlparser.expression.operators.relational.MinorThanEquals) Multiplication(net.sf.jsqlparser.expression.operators.arithmetic.Multiplication) OrExpression(net.sf.jsqlparser.expression.operators.conditional.OrExpression) StatementExecutionException(herddb.model.StatementExecutionException) AndExpression(net.sf.jsqlparser.expression.operators.conditional.AndExpression) GreaterThan(net.sf.jsqlparser.expression.operators.relational.GreaterThan) Division(net.sf.jsqlparser.expression.operators.arithmetic.Division) MinorThan(net.sf.jsqlparser.expression.operators.relational.MinorThan) Addition(net.sf.jsqlparser.expression.operators.arithmetic.Addition) Modulo(net.sf.jsqlparser.expression.operators.arithmetic.Modulo) NotEqualsTo(net.sf.jsqlparser.expression.operators.relational.NotEqualsTo) GreaterThanEquals(net.sf.jsqlparser.expression.operators.relational.GreaterThanEquals) LikeExpression(net.sf.jsqlparser.expression.operators.relational.LikeExpression) Subtraction(net.sf.jsqlparser.expression.operators.arithmetic.Subtraction) EqualsTo(net.sf.jsqlparser.expression.operators.relational.EqualsTo) NotEqualsTo(net.sf.jsqlparser.expression.operators.relational.NotEqualsTo)

Aggregations

StatementExecutionException (herddb.model.StatementExecutionException)1 Addition (net.sf.jsqlparser.expression.operators.arithmetic.Addition)1 Division (net.sf.jsqlparser.expression.operators.arithmetic.Division)1 Modulo (net.sf.jsqlparser.expression.operators.arithmetic.Modulo)1 Multiplication (net.sf.jsqlparser.expression.operators.arithmetic.Multiplication)1 Subtraction (net.sf.jsqlparser.expression.operators.arithmetic.Subtraction)1 AndExpression (net.sf.jsqlparser.expression.operators.conditional.AndExpression)1 OrExpression (net.sf.jsqlparser.expression.operators.conditional.OrExpression)1 EqualsTo (net.sf.jsqlparser.expression.operators.relational.EqualsTo)1 GreaterThan (net.sf.jsqlparser.expression.operators.relational.GreaterThan)1 GreaterThanEquals (net.sf.jsqlparser.expression.operators.relational.GreaterThanEquals)1 LikeExpression (net.sf.jsqlparser.expression.operators.relational.LikeExpression)1 MinorThan (net.sf.jsqlparser.expression.operators.relational.MinorThan)1 MinorThanEquals (net.sf.jsqlparser.expression.operators.relational.MinorThanEquals)1 NotEqualsTo (net.sf.jsqlparser.expression.operators.relational.NotEqualsTo)1