use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.
the class SqlppListInputFunctionRewriteVisitor method visit.
@Override
public Expression visit(CallExpr callExpr, ILangExpression arg) throws CompilationException {
List<Expression> newExprList = new ArrayList<>();
for (Expression expr : callExpr.getExprList()) {
newExprList.add(expr.accept(this, arg));
}
callExpr.setExprList(newExprList);
return FunctionMapUtil.normalizedListInputFunctions(callExpr);
}
use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.
the class SubstituteGroupbyExpressionVisitor method visit.
@Override
public Expression visit(SelectBlock selectBlock, ILangExpression arg) throws CompilationException {
if (selectBlock.hasGroupbyClause()) {
Map<Expression, Expression> map = new HashMap<>();
for (GbyVariableExpressionPair gbyKeyPair : selectBlock.getGroupbyClause().getGbyPairList()) {
Expression gbyKeyExpr = gbyKeyPair.getExpr();
if (gbyKeyExpr.getKind() != Kind.VARIABLE_EXPRESSION) {
map.put(gbyKeyExpr, gbyKeyPair.getVar());
}
}
// Creates a substitution visitor.
SubstituteGroupbyExpressionVisitor visitor = new SubstituteGroupbyExpressionVisitor(context, map);
// Rewrites LET/HAVING/SELECT clauses.
if (selectBlock.hasLetClausesAfterGroupby()) {
for (LetClause letClause : selectBlock.getLetListAfterGroupby()) {
letClause.accept(this, arg);
}
}
if (selectBlock.hasHavingClause()) {
selectBlock.getHavingClause().accept(visitor, arg);
}
selectBlock.getSelectClause().accept(visitor, arg);
SelectExpression selectExpression = (SelectExpression) arg;
// For SET operation queries, the GROUP BY key variables will not substitute ORDER BY nor LIMIT expressions.
if (!selectExpression.getSelectSetOperation().hasRightInputs()) {
if (selectExpression.hasOrderby()) {
selectExpression.getOrderbyClause().accept(visitor, arg);
}
if (selectExpression.hasLimit()) {
selectExpression.getLimitClause().accept(visitor, arg);
}
}
}
return super.visit(selectBlock, arg);
}
use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.
the class GatherFunctionCallsVisitor method visit.
@Override
public Void visit(InsertStatement wc, Void arg) throws CompilationException {
wc.getQuery().accept(this, arg);
Expression returnExpression = wc.getReturnExpression();
if (returnExpression != null) {
returnExpression.accept(this, arg);
}
return null;
}
use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.
the class QueryPrintVisitor method visit.
@Override
public Void visit(GroupbyClause gc, Integer step) throws CompilationException {
out.println(skip(step) + "Groupby");
for (GbyVariableExpressionPair pair : gc.getGbyPairList()) {
if (pair.getVar() != null) {
pair.getVar().accept(this, step + 1);
out.println(skip(step + 1) + ":=");
}
pair.getExpr().accept(this, step + 1);
}
if (gc.hasDecorList()) {
out.println(skip(step + 1) + "Decor");
for (GbyVariableExpressionPair pair : gc.getDecorPairList()) {
if (pair.getVar() != null) {
pair.getVar().accept(this, step + 1);
out.println(skip(step + 1) + ":=");
}
pair.getExpr().accept(this, step + 1);
}
}
if (gc.hasWithMap()) {
out.println(skip(step + 1) + "With");
for (Entry<Expression, VariableExpr> entry : gc.getWithVarMap().entrySet()) {
Expression key = entry.getKey();
VariableExpr value = entry.getValue();
key.accept(this, step + 1);
if (!key.equals(value)) {
out.println(skip(step + 1) + "AS");
value.accept(this, step + 1);
}
}
}
out.println();
return null;
}
use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.
the class QueryPrintVisitor method visit.
@Override
public Void visit(CallExpr pf, Integer step) throws CompilationException {
out.println(skip(step) + "FunctionCall " + pf.getFunctionSignature().toString() + "[");
for (Expression expr : pf.getExprList()) {
expr.accept(this, step + 1);
}
out.println(skip(step) + "]");
return null;
}
Aggregations