private QueryProperties analyze(String sql, boolean fullAnalyze) throws Exception {
    SessionState.start(conf);

    Context context = new Context(conf);
    ASTNode node = ParseUtils.parse(sql, context);

    QueryState state = new QueryState.Builder().withHiveConf(conf).build();
    HiveTxnManager txnManager = mock(DbTxnManager.class);
    when(txnManager.supportsAcid()).thenReturn(true);
    state.setTxnManager(txnManager);

    HiveConf.setBoolVar(state.getConf(), ConfVars.HIVE_CBO_ENABLED, useCbo);
    analyzer = (SemanticAnalyzer) SemanticAnalyzerFactory.get(state, node);

    analyzer.initCtx(context);
    analyzer.init(false);
    if (fullAnalyze) {
      analyzer.analyze(node, context);
    } else {
      // CalcitePlanner#genOPTree is invoked in analyzeInternal, and it cleans up QueryProperties
      // That's why we call only genResolvedParseTree here
      analyzer.genResolvedParseTree(node, null);
    }
    return analyzer.getQueryProperties();
  }
Some unit tests expect the whole analyze process to run, which is the expected, preferred way.
@param sql the query to analyze
@param fullAnalyze whether to run the full analyze or just some parts of it
@return QueryProperties from the analyzer
ql/src/test/org/apache/hadoop/hive/ql/parse/TestQueryProperties.java