Search in sources :

Example 6 with AbstractBinaryCorrelateClause

use of org.apache.asterix.lang.sqlpp.clause.AbstractBinaryCorrelateClause in project asterixdb by apache.

the class SqlppAstPrintVisitor method visit.

@Override
public Void visit(FromTerm fromTerm, Integer step) throws CompilationException {
    fromTerm.getLeftExpression().accept(this, step);
    out.print(skip(step) + "AS ");
    fromTerm.getLeftVariable().accept(this, 0);
    if (fromTerm.hasPositionalVariable()) {
        out.println(" AT ");
        fromTerm.getPositionalVariable().accept(this, 0);
    }
    if (fromTerm.hasCorrelateClauses()) {
        for (AbstractBinaryCorrelateClause correlateClause : fromTerm.getCorrelateClauses()) {
            correlateClause.accept(this, step);
        }
    }
    return null;
}
Also used : AbstractBinaryCorrelateClause(org.apache.asterix.lang.sqlpp.clause.AbstractBinaryCorrelateClause)

Example 7 with AbstractBinaryCorrelateClause

use of org.apache.asterix.lang.sqlpp.clause.AbstractBinaryCorrelateClause in project asterixdb by apache.

the class SqlppInlineUdfsVisitor method visit.

@Override
public Boolean visit(FromTerm fromTerm, List<FunctionDecl> func) throws CompilationException {
    boolean changed = false;
    Pair<Boolean, Expression> p = inlineUdfsInExpr(fromTerm.getLeftExpression(), func);
    fromTerm.setLeftExpression(p.second);
    changed |= p.first;
    for (AbstractBinaryCorrelateClause correlateClause : fromTerm.getCorrelateClauses()) {
        changed |= correlateClause.accept(this, func);
    }
    return changed;
}
Also used : AbstractBinaryCorrelateClause(org.apache.asterix.lang.sqlpp.clause.AbstractBinaryCorrelateClause) CaseExpression(org.apache.asterix.lang.sqlpp.expression.CaseExpression) Expression(org.apache.asterix.lang.common.base.Expression) SelectExpression(org.apache.asterix.lang.sqlpp.expression.SelectExpression)

Example 8 with AbstractBinaryCorrelateClause

use of org.apache.asterix.lang.sqlpp.clause.AbstractBinaryCorrelateClause in project asterixdb by apache.

the class DeepCopyVisitor method visit.

@Override
public FromTerm visit(FromTerm fromTerm, Void arg) throws CompilationException {
    // Visit the left expression of a from term.
    Expression fromExpr = (Expression) fromTerm.getLeftExpression().accept(this, arg);
    VariableExpr fromVar = (VariableExpr) fromTerm.getLeftVariable().accept(this, arg);
    VariableExpr positionVar = fromTerm.getPositionalVariable() == null ? null : (VariableExpr) fromTerm.getPositionalVariable().accept(this, arg);
    // Visits join/unnest/nest clauses.
    List<AbstractBinaryCorrelateClause> correlateClauses = new ArrayList<>();
    for (AbstractBinaryCorrelateClause correlateClause : fromTerm.getCorrelateClauses()) {
        correlateClauses.add((AbstractBinaryCorrelateClause) correlateClause.accept(this, arg));
    }
    return new FromTerm(fromExpr, fromVar, positionVar, correlateClauses);
}
Also used : AbstractBinaryCorrelateClause(org.apache.asterix.lang.sqlpp.clause.AbstractBinaryCorrelateClause) ILangExpression(org.apache.asterix.lang.common.base.ILangExpression) Expression(org.apache.asterix.lang.common.base.Expression) SelectExpression(org.apache.asterix.lang.sqlpp.expression.SelectExpression) CaseExpression(org.apache.asterix.lang.sqlpp.expression.CaseExpression) QuantifiedExpression(org.apache.asterix.lang.common.expression.QuantifiedExpression) ArrayList(java.util.ArrayList) VariableExpr(org.apache.asterix.lang.common.expression.VariableExpr) FromTerm(org.apache.asterix.lang.sqlpp.clause.FromTerm)

Example 9 with AbstractBinaryCorrelateClause

use of org.apache.asterix.lang.sqlpp.clause.AbstractBinaryCorrelateClause in project asterixdb by apache.

the class SqlppVariableUtil method getBindingVariables.

public static Collection<VariableExpr> getBindingVariables(FromTerm fromTerm) {
    List<VariableExpr> bindingVars = new ArrayList<>();
    if (fromTerm == null) {
        return bindingVars;
    }
    bindingVars.add(fromTerm.getLeftVariable());
    if (fromTerm.hasPositionalVariable()) {
        bindingVars.add(fromTerm.getPositionalVariable());
    }
    for (AbstractBinaryCorrelateClause correlateClause : fromTerm.getCorrelateClauses()) {
        bindingVars.add(correlateClause.getRightVariable());
        if (correlateClause.hasPositionalVariable()) {
            bindingVars.add(correlateClause.getPositionalVariable());
        }
    }
    return bindingVars;
}
Also used : AbstractBinaryCorrelateClause(org.apache.asterix.lang.sqlpp.clause.AbstractBinaryCorrelateClause) ArrayList(java.util.ArrayList) VariableExpr(org.apache.asterix.lang.common.expression.VariableExpr)

Aggregations

AbstractBinaryCorrelateClause (org.apache.asterix.lang.sqlpp.clause.AbstractBinaryCorrelateClause)9 VariableExpr (org.apache.asterix.lang.common.expression.VariableExpr)5 Expression (org.apache.asterix.lang.common.base.Expression)4 CaseExpression (org.apache.asterix.lang.sqlpp.expression.CaseExpression)4 SelectExpression (org.apache.asterix.lang.sqlpp.expression.SelectExpression)4 ArrayList (java.util.ArrayList)3 ILangExpression (org.apache.asterix.lang.common.base.ILangExpression)3 FromTerm (org.apache.asterix.lang.sqlpp.clause.FromTerm)2 Pair (org.apache.hyracks.algebricks.common.utils.Pair)2 HashSet (java.util.HashSet)1 GbyVariableExpressionPair (org.apache.asterix.lang.common.expression.GbyVariableExpressionPair)1 QuantifiedExpression (org.apache.asterix.lang.common.expression.QuantifiedExpression)1 VariableSubstitutionEnvironment (org.apache.asterix.lang.common.rewrites.VariableSubstitutionEnvironment)1 Mutable (org.apache.commons.lang3.mutable.Mutable)1 MutableObject (org.apache.commons.lang3.mutable.MutableObject)1 ILogicalExpression (org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression)1 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)1 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)1 AbstractFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression)1 AggregateFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AggregateFunctionCallExpression)1