use of com.alibaba.cobar.parser.ast.expression.Expression in project cobar by alibaba.
the class PartitionKeyVisitor method visit.
@Override
public void visit(ComparisionIsExpression node) {
Expression operand = node.getOperand();
visitChild(2, false, false, operand);
if (verdictColumn && (operand instanceof Identifier)) {
Identifier col = (Identifier) operand;
String table = tableAlias.get(col.getLevelUnescapeUpName(2));
if (isRuledColumn(table, col.getIdTextUpUnescape())) {
switch(node.getMode()) {
case ComparisionIsExpression.IS_FALSE:
addColumnValue(table, col.getIdTextUpUnescape(), LiteralBoolean.FALSE, node, null);
break;
case ComparisionIsExpression.IS_TRUE:
addColumnValue(table, col.getIdTextUpUnescape(), LiteralBoolean.TRUE, node, null);
break;
case ComparisionIsExpression.IS_NULL:
addColumnValue(table, col.getIdTextUpUnescape(), null, node, null);
break;
}
}
}
}
use of com.alibaba.cobar.parser.ast.expression.Expression in project cobar by alibaba.
the class PartitionByLong method constructFunction.
@Override
public FunctionExpression constructFunction(List<Expression> arguments) {
if (arguments == null || arguments.size() != 1)
throw new IllegalArgumentException("function " + getFunctionName() + " must have 1 argument but is " + arguments);
Object[] args = new Object[arguments.size()];
int i = -1;
for (Expression arg : arguments) {
args[++i] = arg;
}
return (FunctionExpression) constructMe(args);
}
use of com.alibaba.cobar.parser.ast.expression.Expression in project cobar by alibaba.
the class PartitionKeyVisitor method visit.
@Override
public void visit(BinaryOperatorExpression node) {
Expression left = node.getLeftOprand();
Expression right = node.getRightOprand();
visitChild(2, false, false, left, right);
}
use of com.alibaba.cobar.parser.ast.expression.Expression in project cobar by alibaba.
the class PartitionKeyVisitor method visit.
@Override
public void visit(DMLDeleteStatement node) {
TableReference tr = node.getTableRefs();
List<Identifier> tbs = node.getTableNames();
if (tr == null) {
Identifier table = tbs.get(0);
tableAsTableFactor(table);
} else {
visitChild(1, verdictColumn, false, tr);
for (Identifier tb : tbs) {
if (tb instanceof Wildcard) {
int trim = tb.trimParent(2, trimSchema);
schemaTrimmed = schemaTrimmed || trim == Identifier.PARENT_TRIMED;
customedSchema = customedSchema || trim == Identifier.PARENT_IGNORED;
} else {
int trim = tb.trimParent(1, trimSchema);
schemaTrimmed = schemaTrimmed || trim == Identifier.PARENT_TRIMED;
customedSchema = customedSchema || trim == Identifier.PARENT_IGNORED;
}
}
}
Expression where = node.getWhereCondition();
visitChild(2, verdictColumn, false, where);
if (tr == null) {
OrderBy order = node.getOrderBy();
visitChild(2, false, false, order);
}
}
use of com.alibaba.cobar.parser.ast.expression.Expression in project cobar by alibaba.
the class PartitionKeyVisitor method visit.
@Override
public void visit(BetweenAndExpression node) {
Expression fst = node.getFirst();
Expression snd = node.getSecond();
Expression trd = node.getThird();
visitChild(2, false, false, fst, snd, trd);
if (verdictColumn && !node.isNot() && fst instanceof Identifier) {
Identifier col = (Identifier) fst;
String table = tableAlias.get(col.getLevelUnescapeUpName(2));
if (isRuledColumn(table, col.getIdTextUpUnescape())) {
Object e1 = snd.evaluation(evaluationParameter);
Object e2 = trd.evaluation(evaluationParameter);
if (e1 != Expression.UNEVALUATABLE && e2 != Expression.UNEVALUATABLE && e1 != null && e2 != null) {
if (compareEvaluatedValue(e1, e2)) {
addColumnValue(table, col.getIdTextUpUnescape(), e1, node, null);
}
}
}
}
}
Aggregations