private static String canHandleQbForCbo(QueryProperties queryProperties,
                                          HiveConf conf, boolean topLevelQB) {
    List<String> reasons = new ArrayList<>();
    // Not ok to run CBO, build error message.
    if (queryProperties.hasSortBy() && queryProperties.hasLimit()) {
      reasons.add("has sort by with limit");
    }
    if (queryProperties.hasPTF()) {
      reasons.add("has PTF");
    }
    if (queryProperties.usesScript()) {
      reasons.add("uses scripts");
    }
    if (!queryProperties.isCBOSupportedLateralViews()) {
      reasons.add("has lateral views");
    }
    return reasons.isEmpty() ? null : String.join("; ", reasons);
  }
Checks whether Calcite can handle the query.

@param queryProperties
@param conf
@param topLevelQB
         Does QB corresponds to top most query block?
@return null if the query can be handled; non-null reason string if it
        cannot be.

        Assumption:<br>
        1. If top level QB is query then everything below it must also be
        Query<br>
        2. Nested Subquery will return false for qbToChk.getIsQuery()
ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java