Search in sources :

Example 91 with Expression

use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.

the class DeepCopyVisitor method visit.

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

Example 92 with Expression

use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.

the class DeepCopyVisitor method visit.

@Override
public IfExpr visit(IfExpr ifExpr, Void arg) throws CompilationException {
    Expression conditionExpr = (Expression) ifExpr.getCondExpr().accept(this, arg);
    Expression thenExpr = (Expression) ifExpr.getThenExpr().accept(this, arg);
    Expression elseExpr = (Expression) ifExpr.getElseExpr().accept(this, arg);
    return new IfExpr(conditionExpr, thenExpr, elseExpr);
}
Also used : IfExpr(org.apache.asterix.lang.common.expression.IfExpr) 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)

Example 93 with Expression

use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.

the class VariableCheckAndRewriteVisitor method visit.

@Override
public Expression visit(FieldAccessor fa, ILangExpression parent) throws CompilationException {
    Expression leadingExpr = fa.getExpr();
    if (leadingExpr.getKind() != Kind.VARIABLE_EXPRESSION) {
        fa.setExpr(leadingExpr.accept(this, fa));
        return fa;
    } else {
        VariableExpr varExpr = (VariableExpr) leadingExpr;
        String lastIdentifier = fa.getIdent().getValue();
        Expression resolvedExpr = resolve(varExpr, /** Resolves within the dataverse that has the same name as the variable name. */
        SqlppVariableUtil.toUserDefinedVariableName(varExpr.getVar().getValue()).getValue(), lastIdentifier, fa, parent);
        if (resolvedExpr.getKind() == Kind.CALL_EXPRESSION) {
            CallExpr callExpr = (CallExpr) resolvedExpr;
            if (callExpr.getFunctionSignature().equals(datasetFunction)) {
                // The field access is resolved to be a dataset access in the form of "dataverse.dataset".
                return resolvedExpr;
            }
        }
        fa.setExpr(resolvedExpr);
        return fa;
    }
}
Also used : Expression(org.apache.asterix.lang.common.base.Expression) ILangExpression(org.apache.asterix.lang.common.base.ILangExpression) VariableExpr(org.apache.asterix.lang.common.expression.VariableExpr) CallExpr(org.apache.asterix.lang.common.expression.CallExpr)

Example 94 with Expression

use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.

the class VariableCheckAndRewriteVisitor method wrapWithDatasetFunction.

private Expression wrapWithDatasetFunction(String dataverseName, String datasetName) throws CompilationException {
    String fullyQualifiedName = dataverseName == null ? datasetName : dataverseName + "." + datasetName;
    List<Expression> argList = new ArrayList<>();
    argList.add(new LiteralExpr(new StringLiteral(fullyQualifiedName)));
    return new CallExpr(datasetFunction, argList);
}
Also used : StringLiteral(org.apache.asterix.lang.common.literal.StringLiteral) Expression(org.apache.asterix.lang.common.base.Expression) ILangExpression(org.apache.asterix.lang.common.base.ILangExpression) ArrayList(java.util.ArrayList) LiteralExpr(org.apache.asterix.lang.common.expression.LiteralExpr) CallExpr(org.apache.asterix.lang.common.expression.CallExpr)

Example 95 with Expression

use of org.apache.asterix.lang.common.base.Expression 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)

Aggregations

Expression (org.apache.asterix.lang.common.base.Expression)105 ILangExpression (org.apache.asterix.lang.common.base.ILangExpression)75 QuantifiedExpression (org.apache.asterix.lang.common.expression.QuantifiedExpression)52 SelectExpression (org.apache.asterix.lang.sqlpp.expression.SelectExpression)41 ArrayList (java.util.ArrayList)37 VariableExpr (org.apache.asterix.lang.common.expression.VariableExpr)36 Pair (org.apache.hyracks.algebricks.common.utils.Pair)35 GbyVariableExpressionPair (org.apache.asterix.lang.common.expression.GbyVariableExpressionPair)32 CaseExpression (org.apache.asterix.lang.sqlpp.expression.CaseExpression)32 QuantifiedPair (org.apache.asterix.lang.common.struct.QuantifiedPair)22 ILogicalExpression (org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression)19 VariableReferenceExpression (org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression)19 FLWOGRExpression (org.apache.asterix.lang.aql.expression.FLWOGRExpression)17 Mutable (org.apache.commons.lang3.mutable.Mutable)17 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)17 AbstractFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression)16 AggregateFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AggregateFunctionCallExpression)16 ConstantExpression (org.apache.hyracks.algebricks.core.algebra.expressions.ConstantExpression)16 ScalarFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression)16 UnnestingFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.UnnestingFunctionCallExpression)16