/** * Generate the ANSI SQL92 filter for the given expression tree * @param table the table being queried * @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 */ public static String generateSqlFilter(Table table, ExpressionTree tree, List<String> params, List<String> joins) throws MetaException { assert table != null; if (tree.getRoot() == null) { return ""; } PartitionFilterGenerator visitor = new PartitionFilterGenerator(table, params, joins); tree.getRoot().accept(visitor); // Some joins might be null (see processNode for LeafNode), clean them up. for (int i = 0; i < joins.size(); ++i) { if (joins.get(i) != null) continue; joins.remove(i--); } return "and (" + visitor.filterBuffer.toString() + ")"; }
@Override public void visit(TreeNode node) throws MetaException { assert node != null && node.getLhs() != null && node.getRhs() != null; filterBuffer.append (" ("); node.getLhs().accept(this); filterBuffer.append((node.getAndOr() == LogicalOperator.AND) ? " and " : " or "); node.getRhs().accept(this); filterBuffer.append (") "); }
public void accept(TreeVisitor treeVisitor) throws MetaException { if (this.root != null) { this.root.accept(treeVisitor); } }
public void accept(TreeVisitor treeVisitor) throws MetaException { if (this.root != null) { this.root.accept(treeVisitor); } }
public void accept(TreeVisitor treeVisitor) throws MetaException { if (this.root != null) { this.root.accept(treeVisitor); } }