private boolean queryTypeCanUseCache(QB qb) {
    if (qb == null || qb.getParseInfo() == null) {
      return false;
    }
    if (this instanceof ColumnStatsSemanticAnalyzer) {
      // Column stats generates "select compute_stats() .." queries.
      // Disable caching for these.
      LOG.debug("Query type cannot use cache (ColumnStatsSemanticAnalyzer)");
      return false;
    }
    if (queryState.getHiveOperation() != HiveOperation.QUERY) {
      LOG.debug("Query type cannot use cache (HiveOperation is not a QUERY)");
      return false;
    }
    if (Optional.of(qb.getParseInfo()).filter(pi ->
            pi.isAnalyzeCommand() || pi.hasInsertTables() || pi.isInsertOverwriteDirectory())
        .isPresent()) {
      LOG.debug("Query type cannot use cache (analyze, insert, or IOWD)");
      return false;
    }
    // HIVE-19096 - disable for explain and explain analyze
    if (ctx.getExplainAnalyze() != null) {
      LOG.debug("Query type cannot use cache (explain analyze command)");
      return false;
    }

    return true;
  }
Some initial checks for a query to see if we can look this query up in the results cache.
ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java