Search in sources :

Example 1 with NestClause

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

the class SqlppCloneAndSubstituteVariablesVisitor method visit.

@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(NestClause nestClause, VariableSubstitutionEnvironment env) throws CompilationException {
    VariableExpr rightVar = nestClause.getRightVariable();
    VariableExpr newRightVar = generateNewVariable(context, rightVar);
    VariableExpr newRightPosVar = nestClause.hasPositionalVariable() ? generateNewVariable(context, nestClause.getPositionalVariable()) : null;
    // Visits the right expression.
    Expression rightExpr = (Expression) nestClause.getRightExpression().accept(this, env).first;
    // Visits the condition.
    VariableSubstitutionEnvironment currentEnv = new VariableSubstitutionEnvironment(env);
    currentEnv.removeSubstitution(newRightVar);
    if (newRightPosVar != null) {
        currentEnv.removeSubstitution(newRightPosVar);
    }
    // The condition can refer to the newRightVar and newRightPosVar.
    Expression conditionExpr = (Expression) nestClause.getConditionExpression().accept(this, currentEnv).first;
    NestClause newJoinClause = new NestClause(nestClause.getJoinType(), rightExpr, newRightVar, newRightPosVar, conditionExpr);
    return new Pair<>(newJoinClause, currentEnv);
}
Also used : VariableSubstitutionEnvironment(org.apache.asterix.lang.common.rewrites.VariableSubstitutionEnvironment) ILangExpression(org.apache.asterix.lang.common.base.ILangExpression) CaseExpression(org.apache.asterix.lang.sqlpp.expression.CaseExpression) Expression(org.apache.asterix.lang.common.base.Expression) SelectExpression(org.apache.asterix.lang.sqlpp.expression.SelectExpression) NestClause(org.apache.asterix.lang.sqlpp.clause.NestClause) VariableExpr(org.apache.asterix.lang.common.expression.VariableExpr) Pair(org.apache.hyracks.algebricks.common.utils.Pair)

Example 2 with NestClause

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

the class DeepCopyVisitor method visit.

@Override
public NestClause visit(NestClause nestClause, Void arg) throws CompilationException {
    Expression rightExpression = (Expression) nestClause.getRightExpression().accept(this, arg);
    VariableExpr rightVar = (VariableExpr) nestClause.getRightVariable().accept(this, arg);
    VariableExpr rightPositionVar = nestClause.getPositionalVariable() == null ? null : (VariableExpr) nestClause.getPositionalVariable().accept(this, arg);
    Expression conditionExpresion = (Expression) nestClause.getConditionExpression().accept(this, arg);
    return new NestClause(nestClause.getJoinType(), rightExpression, rightVar, rightPositionVar, conditionExpresion);
}
Also used : 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) NestClause(org.apache.asterix.lang.sqlpp.clause.NestClause) VariableExpr(org.apache.asterix.lang.common.expression.VariableExpr)

Aggregations

Expression (org.apache.asterix.lang.common.base.Expression)2 ILangExpression (org.apache.asterix.lang.common.base.ILangExpression)2 VariableExpr (org.apache.asterix.lang.common.expression.VariableExpr)2 NestClause (org.apache.asterix.lang.sqlpp.clause.NestClause)2 CaseExpression (org.apache.asterix.lang.sqlpp.expression.CaseExpression)2 SelectExpression (org.apache.asterix.lang.sqlpp.expression.SelectExpression)2 QuantifiedExpression (org.apache.asterix.lang.common.expression.QuantifiedExpression)1 VariableSubstitutionEnvironment (org.apache.asterix.lang.common.rewrites.VariableSubstitutionEnvironment)1 Pair (org.apache.hyracks.algebricks.common.utils.Pair)1