use of org.voltdb.expressions.AbstractExpression in project voltdb by VoltDB.
the class AbstractParsedStmt method rejectDisallowedRowOpExpressions.
private void rejectDisallowedRowOpExpressions(AbstractExpression expr) {
ExpressionType exprType = expr.getExpressionType();
// searching for row op subquery expressions.
if (ExpressionType.CONJUNCTION_AND == exprType || ExpressionType.CONJUNCTION_OR == exprType) {
rejectDisallowedRowOpExpressions(expr.getLeft());
rejectDisallowedRowOpExpressions(expr.getRight());
return;
}
if (ExpressionType.OPERATOR_NOT == exprType) {
rejectDisallowedRowOpExpressions(expr.getLeft());
}
// The problem cases are all comparison ops.
if (!(expr instanceof ComparisonExpression)) {
return;
}
// The problem cases all have row expressions as an operand.
AbstractExpression rowExpression = expr.getLeft();
if (rowExpression instanceof RowSubqueryExpression) {
rejectDisallowedRowColumns(rowExpression);
}
rowExpression = expr.getRight();
if (rowExpression instanceof RowSubqueryExpression) {
rejectDisallowedRowColumns(rowExpression);
}
}
use of org.voltdb.expressions.AbstractExpression in project voltdb by VoltDB.
the class AccessPath method toString.
@Override
public String toString() {
String retval = "";
retval += "INDEX: " + ((index == null) ? "NULL" : (index.getParent().getTypeName() + "." + index.getTypeName())) + "\n";
retval += "USE: " + use.toString() + "\n";
retval += "FOR: " + indexPurposeString() + "\n";
retval += "TYPE: " + lookupType.toString() + "\n";
retval += "DIR: " + sortDirection.toString() + "\n";
retval += "ITER?: " + String.valueOf(keyIterate) + "\n";
retval += "NLIJ?: " + String.valueOf(nestLoopIndexJoin) + "\n";
retval += "IDX EXPRS:\n";
int i = 0;
for (AbstractExpression expr : indexExprs) retval += "\t(" + String.valueOf(i++) + ") " + expr.toString() + "\n";
retval += "END EXPRS:\n";
i = 0;
for (AbstractExpression expr : endExprs) retval += "\t(" + String.valueOf(i++) + ") " + expr.toString() + "\n";
retval += "OTHER EXPRS:\n";
i = 0;
for (AbstractExpression expr : otherExprs) retval += "\t(" + String.valueOf(i++) + ") " + expr.toString() + "\n";
retval += "JOIN EXPRS:\n";
i = 0;
for (AbstractExpression expr : joinExprs) retval += "\t(" + String.valueOf(i++) + ") " + expr.toString() + "\n";
retval += "ELIMINATED POST FILTER EXPRS:\n";
i = 0;
for (AbstractExpression expr : eliminatedPostExprs) retval += "\t(" + String.valueOf(i++) + ") " + expr.toString() + "\n";
return retval;
}
use of org.voltdb.expressions.AbstractExpression in project voltdb by VoltDB.
the class AbstractParsedStmt method parseTableCondition.
/** Parse a where or join clause. This behavior is common to all kinds of statements.
*/
private AbstractExpression parseTableCondition(VoltXMLElement tableScan, String joinOrWhere) {
AbstractExpression condExpr = null;
for (VoltXMLElement childNode : tableScan.children) {
if (!childNode.name.equalsIgnoreCase(joinOrWhere)) {
continue;
}
assert (childNode.children.size() == 1);
assert (condExpr == null);
condExpr = parseConditionTree(childNode.children.get(0));
assert (condExpr != null);
ExpressionUtil.finalizeValueTypes(condExpr);
condExpr = ExpressionUtil.evaluateExpression(condExpr);
// If the condition is a trivial CVE(TRUE) (after the evaluation) simply drop it
if (ConstantValueExpression.isBooleanTrue(condExpr)) {
condExpr = null;
}
}
return condExpr;
}
use of org.voltdb.expressions.AbstractExpression in project voltdb by VoltDB.
the class AbstractParsedStmt method parseRowExpression.
/**
*
* @param exprNode
* @return
*/
private AbstractExpression parseRowExpression(List<VoltXMLElement> exprNodes) {
// Parse individual columnref expressions from the IN output schema
List<AbstractExpression> exprs = new ArrayList<>();
for (VoltXMLElement exprNode : exprNodes) {
AbstractExpression expr = parseExpressionNode(exprNode);
exprs.add(expr);
}
return new RowSubqueryExpression(exprs);
}
use of org.voltdb.expressions.AbstractExpression in project voltdb by VoltDB.
the class AbstractParsedStmt method replaceExpressionsWithPve.
/**
* Helper method to replace all TVEs and aggregated expressions with the corresponding PVEs.
* The original expressions are placed into the map to be propagated to the EE.
* The key to the map is the parameter index.
*
*
* @param stmt - subquery statement
* @param expr - expression with parent TVEs
* @return Expression with parent TVE replaced with PVE
*/
protected AbstractExpression replaceExpressionsWithPve(AbstractExpression expr) {
assert (expr != null);
if (expr instanceof TupleValueExpression) {
int paramIdx = NEXT_PARAMETER_ID++;
ParameterValueExpression pve = new ParameterValueExpression(paramIdx, expr);
m_parameterTveMap.put(paramIdx, expr);
return pve;
}
if (expr instanceof AggregateExpression) {
int paramIdx = NEXT_PARAMETER_ID++;
ParameterValueExpression pve = new ParameterValueExpression(paramIdx, expr);
// Disallow aggregation of parent columns in a subquery.
// except the case HAVING AGG(T1.C1) IN (SELECT T2.C2 ...)
List<TupleValueExpression> tves = ExpressionUtil.getTupleValueExpressions(expr);
assert (m_parentStmt != null);
for (TupleValueExpression tve : tves) {
int origId = tve.getOrigStmtId();
if (m_stmtId != origId && m_parentStmt.m_stmtId != origId) {
throw new PlanningErrorException("Subqueries do not support aggregation of parent statement columns");
}
}
m_parameterTveMap.put(paramIdx, expr);
return pve;
}
if (expr.getLeft() != null) {
expr.setLeft(replaceExpressionsWithPve(expr.getLeft()));
}
if (expr.getRight() != null) {
expr.setRight(replaceExpressionsWithPve(expr.getRight()));
}
if (expr.getArgs() != null) {
List<AbstractExpression> newArgs = new ArrayList<>();
for (AbstractExpression argument : expr.getArgs()) {
newArgs.add(replaceExpressionsWithPve(argument));
}
expr.setArgs(newArgs);
}
return expr;
}
Aggregations