use of org.apache.apex.malhar.sql.planner.RelNodeVisitor in project apex-malhar by apache.
the class SQLExecEnvironment method executeSQL.
/**
* This is the main method takes SQL statement as input and contructs a DAG using contructs registered with this
* {@link SQLExecEnvironment}.
*
* @param sql SQL statement that should be converted to a DAG.
*/
public void executeSQL(DAG dag, String sql) {
FrameworkConfig config = buildFrameWorkConfig();
Planner planner = Frameworks.getPlanner(config);
try {
logger.info("Parsing SQL statement: {}", sql);
SqlNode parsedTree = planner.parse(sql);
SqlNode validatedTree = planner.validate(parsedTree);
RelNode relationalTree = planner.rel(validatedTree).rel;
logger.info("RelNode relationalTree generate from SQL statement is:\n {}", Util.toLinux(RelOptUtil.toString(relationalTree)));
RelNodeVisitor visitor = new RelNodeVisitor(dag, typeFactory);
visitor.traverse(relationalTree);
} catch (Exception e) {
throw Throwables.propagate(e);
} finally {
planner.close();
}
}
Aggregations