private boolean checkThreshold(FetchData data, int limit, ParseContext pctx) throws Exception {
    boolean cachingEnabled = HiveConf.getBoolVar(pctx.getConf(), HiveConf.ConfVars.HIVE_FETCH_TASK_CACHING);
    if (!cachingEnabled) {
      if (limit > 0) {
        if (data.hasOnlyPruningFilter()) {
          // partitioned table + query has only pruning filters
          return true;
        } else if (!data.isPartitioned() && !data.isFiltered()) {
          // unpartitioned table + no filters
          return true;
        }
        // fall through
      }
      Operator child = data.scanOp.getChildOperators().get(0);
      if(child instanceof SelectOperator) {
        // select *, constant and casts can be allowed without a threshold check
        if (checkExpressions((SelectOperator)child)) {
          return true;
        }
      }
    }
    // if caching is enabled we apply the treshold in all cases
    long threshold = HiveConf.getLongVar(pctx.getConf(),
        HiveConf.ConfVars.HIVE_FETCH_TASK_CONVERSION_THRESHOLD);
    if (threshold < 0) {
      return true;
    }
    return data.isDataLengthWithInThreshold(pctx, threshold);
  }
Tries to convert simple fetch query to single fetch task, which fetches rows directly
from location of table/partition.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/SimpleFetchOptimizer.java