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;
}
}
Aggregations