Search in sources :

Example 1 with ParseException

use of org.apache.asterix.lang.sqlpp.parser.ParseException in project asterixdb by apache.

the class ExpressionToVariableUtil method getGeneratedVariable.

/**
     * Generates a variable according to an expression.
     *
     * @param expr
     *            the input expression.
     * @param raiseError,
     *            if it is not possible to generate a variable from the input expression,
     *            to raise the error if true, and to return a null if false.
     * @return the generated variable.
     * @throws ParseException
     */
public static VariableExpr getGeneratedVariable(Expression expr, boolean raiseError) throws ParseException {
    try {
        String varName = getGeneratedIdentifier(expr);
        VarIdentifier var = new VarIdentifier(varName);
        VariableExpr varExpr = new VariableExpr();
        varExpr.setVar(var);
        return varExpr;
    } catch (ParseException e) {
        if (raiseError) {
            throw e;
        }
        return null;
    }
}
Also used : VarIdentifier(org.apache.asterix.lang.common.struct.VarIdentifier) VariableExpr(org.apache.asterix.lang.common.expression.VariableExpr) ParseException(org.apache.asterix.lang.sqlpp.parser.ParseException)

Aggregations

VariableExpr (org.apache.asterix.lang.common.expression.VariableExpr)1 VarIdentifier (org.apache.asterix.lang.common.struct.VarIdentifier)1 ParseException (org.apache.asterix.lang.sqlpp.parser.ParseException)1