use of org.apache.drill.common.expression.parser.ExprParser in project drill by apache.
the class TestBuilder method parsePath.
// modified code from SchemaPath.De class. This should be used sparingly and only in tests if absolutely needed.
public static SchemaPath parsePath(String path) {
try {
ExprLexer lexer = new ExprLexer(new ANTLRStringStream(path));
CommonTokenStream tokens = new CommonTokenStream(lexer);
ExprParser parser = new ExprParser(tokens);
ExprParser.parse_return ret = parser.parse();
if (ret.e instanceof SchemaPath) {
return (SchemaPath) ret.e;
} else {
throw new IllegalStateException("Schema path is not a valid format.");
}
} catch (RecognitionException e) {
throw new RuntimeException(e);
}
}
use of org.apache.drill.common.expression.parser.ExprParser in project drill by apache.
the class ExecTest method parseExpr.
protected LogicalExpression parseExpr(String expr) throws RecognitionException {
final ExprLexer lexer = new ExprLexer(new ANTLRStringStream(expr));
final CommonTokenStream tokens = new CommonTokenStream(lexer);
final ExprParser parser = new ExprParser(tokens);
final ExprParser.parse_return ret = parser.parse();
return ret.e;
}
use of org.apache.drill.common.expression.parser.ExprParser in project drill by apache.
the class PhysicalOpUnitTestBase method parseExpr.
@Override
protected LogicalExpression parseExpr(String expr) {
ExprLexer lexer = new ExprLexer(new ANTLRStringStream(expr));
CommonTokenStream tokens = new CommonTokenStream(lexer);
ExprParser parser = new ExprParser(tokens);
try {
return parser.parse().e;
} catch (RecognitionException e) {
throw new RuntimeException("Error parsing expression: " + expr);
}
}
use of org.apache.drill.common.expression.parser.ExprParser in project drill by apache.
the class TestEvaluationVisitor method getExpr.
private LogicalExpression getExpr(String expr) throws Exception {
ExprLexer lexer = new ExprLexer(new ANTLRStringStream(expr));
CommonTokenStream tokens = new CommonTokenStream(lexer);
// tokens.fill();
// for(Token t : (List<Token>) tokens.getTokens()){
// System.out.println(t + "" + t.getType());
// }
// tokens.rewind();
ExprParser parser = new ExprParser(tokens);
parse_return ret = parser.parse();
return ret.e;
}
Aggregations