@Override public ParseNode createNode(List<ParseNode> children) { return NODE_FACTORY.and(children); } });
@Override public ParseNode createNode(List<ParseNode> children) { return NODE_FACTORY.and(children); } });
public ParseNode getExtractedCondition() { if (this.extractedConditions.isEmpty()) return null; if (this.extractedConditions.size() == 1) return this.extractedConditions.get(0); return FACTORY.and(this.extractedConditions); }
private static ParseNode combine(List<ParseNode> nodes) { if (nodes.isEmpty()) return null; if (nodes.size() == 1) return nodes.get(0); return NODE_FACTORY.and(nodes); } }
public ParseNode getJoinCondition() { if (this.joinConditions.isEmpty()) return null; if (this.joinConditions.size() == 1) return this.joinConditions.get(0); return NODE_FACTORY.and(this.joinConditions); }
@Override public ParseNode createNode(List<ParseNode> children) { if (children.isEmpty()) { return null; } if (children.size() == 1) { return children.get(0); } return NODE_FACTORY.and(children); } });
@Override public ParseNode createNode(List<ParseNode> children) { if (children.isEmpty()) { return null; } if (children.size() == 1) { return children.get(0); } return NODE_FACTORY.and(children); } });
private static ParseNode combine(List<ParseNode> nodes) { if (nodes.isEmpty()) return null; if (nodes.size() == 1) return nodes.get(0); return NODE_FACTORY.and(nodes); }
@Override public ParseNode visitLeave(AndParseNode node, List<ParseNode> l) throws SQLException { if (l.equals(node.getChildren())) return node; if (l.isEmpty()) return null; if (l.size() == 1) return l.get(0); return FACTORY.and(l); }
@Override public ParseNode visitLeave(AndParseNode node, List<ParseNode> l) throws SQLException { if (l.equals(node.getChildren())) return node; if (l.isEmpty()) return null; if (l.size() == 1) return l.get(0); return NODE_FACTORY.and(l); }
/** * Rewrite the select statement by filtering out expression nodes from the HAVING clause * and anding them with the WHERE clause. * @param statement the select statement from which to move the nodes. * @param moveNodes expression nodes to filter out of HAVING clause and add to WHERE clause. * @return new select statement * @throws SQLException */ public static SelectStatement moveFromHavingToWhereClause(SelectStatement statement, Set<ParseNode> moveNodes) throws SQLException { if (moveNodes.isEmpty()) { return statement; } ParseNode andNode = NODE_FACTORY.and(new ArrayList<ParseNode>(moveNodes)); ParseNode having = statement.getHaving(); SelectStatementRewriter rewriter = new SelectStatementRewriter(moveNodes); having = having.accept(rewriter); ParseNode where = statement.getWhere(); if (where == null) { where = andNode; } else { where = NODE_FACTORY.and(Arrays.asList(where,andNode)); } // Return new SELECT statement with updated WHERE and HAVING clauses return NODE_FACTORY.select(statement, where, having); }
private ParseNode getJoinConditionNode(ParseNode lhs, List<AliasedNode> rhs, String rhsTableAlias) throws SQLException { List<ParseNode> lhsNodes; if (lhs instanceof RowValueConstructorParseNode) { lhsNodes = ((RowValueConstructorParseNode) lhs).getChildren(); } else { lhsNodes = Collections.singletonList(lhs); } if (lhsNodes.size() != (rhs.size() - 1)) throw new SQLExceptionInfo.Builder(SQLExceptionCode.SUBQUERY_RETURNS_DIFFERENT_NUMBER_OF_FIELDS).build().buildException(); int count = lhsNodes.size(); TableName rhsTableName = NODE_FACTORY.table(null, rhsTableAlias); List<ParseNode> equalNodes = Lists.newArrayListWithExpectedSize(count); for (int i = 0; i < count; i++) { ParseNode rhsNode = NODE_FACTORY.column(rhsTableName, rhs.get(i + 1).getAlias(), null); equalNodes.add(NODE_FACTORY.equal(lhsNodes.get(i), rhsNode)); } return count == 1 ? equalNodes.get(0) : NODE_FACTORY.and(equalNodes); }
if ( state.backtracking==0 ) { ret = l.size() == 1 ? l.get(0) : factory.and(l); }
private static ParseNode combine(List<ParseNode> nodes) { if (nodes.isEmpty()) return null; if (nodes.size() == 1) return nodes.get(0); return NODE_FACTORY.and(nodes); }
private static ParseNode combine(List<ParseNode> nodes) { if (nodes.isEmpty()) return null; if (nodes.size() == 1) return nodes.get(0); return NODE_FACTORY.and(nodes); }
public ParseNode getExtractedCondition() { if (this.extractedConditions.isEmpty()) return null; if (this.extractedConditions.size() == 1) return this.extractedConditions.get(0); return FACTORY.and(this.extractedConditions); }
@Override public ParseNode createNode(List<ParseNode> children) { if (children.isEmpty()) { return null; } if (children.size() == 1) { return children.get(0); } return NODE_FACTORY.and(children); } });
ParseNode extractedCondition = whereRewriter.getExtractedCondition(); if (extractedCondition != null) { outerWhere = FACTORY.and(Lists.newArrayList(outerWhere, extractedCondition));