public static Pair<Boolean, String> unsupportedFeaturesPresentInASTorQB(ASTNode ast, QB qb) {
    Pair<Boolean, String> containsToken = 
        ParseUtils.containsTokenOfType(ast, HiveParser.TOK_CHARSETLITERAL, HiveParser.TOK_TABLESPLITSAMPLE, 
            HiveParser.TOK_UNIQUEJOIN, HiveParser.TOK_TABLEBUCKETSAMPLE);

    if (Boolean.TRUE.equals(containsToken.getKey())) {
      return containsToken;
    }
    if (qb.hasTableSampleRecursive()) {
      return Pair.of(true, "TOK_TABLEBUCKETSAMPLE");
    }

    return Pair.of(false, null);
  }
Generic utility functions needed for Calcite based Hive CBO.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveCalciteUtil.java