private static String generateSqlFilter(String catName, String dbName, String tableName,
        List<FieldSchema> partitionKeys, ExpressionTree tree, List<Object> params,
        List<String> joins, boolean dbHasJoinCastBug, String defaultPartName,
        DatabaseProduct dbType, String schema, boolean compactJoins) throws MetaException {
      if (tree == null) {
        // consistent with other APIs like makeExpressionTree, null is returned to indicate that
        // the filter could not pushed down due to parsing issue etc
        return null;
      }
      if (tree.getRoot() == null) {
        return "";
      }
      PartitionFilterGenerator visitor = new PartitionFilterGenerator(
          catName, dbName, tableName, partitionKeys,
          params, joins, dbHasJoinCastBug, defaultPartName, dbType, schema);
      tree.accept(visitor);
      if (visitor.filterBuffer.hasError()) {
        LOG.info("Unable to push down SQL filter: " + visitor.filterBuffer.getErrorMessage());
        return null;
      }

      // Some joins might be null (see processNode for LeafNode), clean them up.
      if (compactJoins) {
        for (int i = 0; i < joins.size(); ++i) {
          if (joins.get(i) != null) {
            continue;
          }
          joins.remove(i--);
        }
      }
      return "(" + visitor.filterBuffer.getFilter() + ")";
    }
Generate the ANSI SQL92 filter for the given expression tree
@param catName catalog name
@param dbName db name
@param tableName table name
@param partitionKeys partition keys
@param params the ordered parameters for the resulting expression
@param joins the joins necessary for the resulting expression
@return the string representation of the expression tree
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java