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);
}
}
Aggregations