Search in sources :

Example 1 with CalcitePlanner

use of org.apache.hadoop.hive.ql.parse.CalcitePlanner in project hive by apache.

the class HiveMaterializedViewsRegistry method parseQuery.

private static RelNode parseQuery(String viewQuery) {
    try {
        final ASTNode node = ParseUtils.parse(viewQuery);
        final QueryState qs = new QueryState(SessionState.get().getConf());
        CalcitePlanner analyzer = new CalcitePlanner(qs);
        analyzer.initCtx(new Context(SessionState.get().getConf()));
        analyzer.init(false);
        return analyzer.genLogicalPlan(node);
    } catch (Exception e) {
        // We could not parse the view
        return null;
    }
}
Also used : Context(org.apache.hadoop.hive.ql.Context) ASTNode(org.apache.hadoop.hive.ql.parse.ASTNode) CalcitePlanner(org.apache.hadoop.hive.ql.parse.CalcitePlanner) QueryState(org.apache.hadoop.hive.ql.QueryState) CalciteSemanticException(org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSemanticException) SerDeException(org.apache.hadoop.hive.serde2.SerDeException)

Aggregations

Context (org.apache.hadoop.hive.ql.Context)1 QueryState (org.apache.hadoop.hive.ql.QueryState)1 CalciteSemanticException (org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSemanticException)1 ASTNode (org.apache.hadoop.hive.ql.parse.ASTNode)1 CalcitePlanner (org.apache.hadoop.hive.ql.parse.CalcitePlanner)1 SerDeException (org.apache.hadoop.hive.serde2.SerDeException)1