@Override public LimitClause visit(LimitClause limitClause, Void arg) throws CompilationException { Expression limitExpr = (Expression) limitClause.getLimitExpr().accept(this, arg); Expression offsetExpr = limitClause.hasOffset() ? (Expression) limitClause.getOffset().accept(this, arg) : null; LimitClause copy = new LimitClause(limitExpr, offsetExpr); copy.setSourceLocation(limitClause.getSourceLocation()); return copy; }
@Override public Expression visit(LimitClause limitClause, ILangExpression arg) throws CompilationException { limitClause.setLimitExpr(visit(limitClause.getLimitExpr(), limitClause)); if (limitClause.hasOffset()) { limitClause.setOffset(visit(limitClause.getOffset(), limitClause)); } return null; }
@Override public boolean equals(Object object) { if (this == object) { return true; } if (!(object instanceof LimitClause)) { return false; } LimitClause target = (LimitClause) object; return limitExpr.equals(target.getLimitExpr()) && Objects.equals(offset, target.getOffset()); } }
final public LimitClause LimitClause() throws ParseException, ParseException { LimitClause lc = new LimitClause(); Expression expr; pushForbiddenScope(getCurrentScope()); jj_consume_token(LIMIT); expr = Expression(); lc.setLimitExpr(expr); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case OFFSET: jj_consume_token(OFFSET); expr = Expression(); lc.setOffset(expr); break; default: jj_la1[114] = jj_gen; ; } popForbiddenScope(); {if (true) return lc;} throw new Error("Missing return statement in function"); }
@Override public Pair<ILogicalOperator, LogicalVariable> visit(LimitClause lc, Mutable<ILogicalOperator> tupSource) throws CompilationException { SourceLocation sourceLoc = lc.getSourceLocation(); LimitOperator opLim; Pair<ILogicalExpression, Mutable<ILogicalOperator>> p1 = langExprToAlgExpression(lc.getLimitExpr(), tupSource); ILogicalExpression maxObjectsExpr = createLimitOffsetValueExpression(p1.first, lc.getLimitExpr().getSourceLocation()); Expression offset = lc.getOffset(); if (offset != null) { Pair<ILogicalExpression, Mutable<ILogicalOperator>> p2 = langExprToAlgExpression(offset, p1.second); ILogicalExpression offsetExpr = createLimitOffsetValueExpression(p2.first, lc.getOffset().getSourceLocation()); opLim = new LimitOperator(maxObjectsExpr, offsetExpr); opLim.getInputs().add(p2.second); opLim.setSourceLocation(sourceLoc); } else { opLim = new LimitOperator(maxObjectsExpr); opLim.getInputs().add(p1.second); opLim.setSourceLocation(sourceLoc); } return new Pair<>(opLim, null); }
@Override public Void visit(SelectExpression selectExpression, Collection<VariableExpr> freeVars) throws CompilationException { Collection<VariableExpr> letsFreeVars = new HashSet<>(); Collection<VariableExpr> selectFreeVars = new HashSet<>(); visitLetWhereClauses(selectExpression.getLetList(), letsFreeVars); // visit order by if (selectExpression.hasOrderby()) { for (Expression orderExpr : selectExpression.getOrderbyClause().getOrderbyList()) { orderExpr.accept(this, selectFreeVars); } } // visit limit if (selectExpression.hasLimit()) { selectExpression.getLimitClause().accept(this, selectFreeVars); } // visit the main select selectExpression.getSelectSetOperation().accept(this, selectFreeVars); // Removed let binding variables. selectFreeVars.removeAll(SqlppVariableUtil.getLetBindingVariables(selectExpression.getLetList())); freeVars.addAll(letsFreeVars); freeVars.addAll(selectFreeVars); return null; }
@Override public Void visit(LimitClause limitClause, Collection<VariableExpr> freeVars) throws CompilationException { limitClause.getLimitExpr().accept(this, freeVars); return null; }
final public LimitClause LimitClause() throws ParseException, ParseException { LimitClause lc = new LimitClause(); Expression expr; pushForbiddenScope(getCurrentScope()); jj_consume_token(LIMIT); expr = Expression(); lc.setLimitExpr(expr); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case OFFSET: jj_consume_token(OFFSET); expr = Expression(); lc.setOffset(expr); break; default: jj_la1[0] = jj_gen; ; } popForbiddenScope(); {if (true) return lc;} throw new Error("Missing return statement in function"); }
@Override public Void visit(LimitClause lc, Void arg) throws CompilationException { lc.getLimitExpr().accept(this, arg); if (lc.getOffset() != null) { lc.getOffset().accept(this, arg); } return null; }
@Override public Void visit(SelectExpression selectStatement, Void arg) throws CompilationException { selectStatement.getSelectSetOperation().accept(this, arg); if (selectStatement.hasOrderby()) { selectStatement.getOrderbyClause().accept(this, arg); } if (selectStatement.hasLimit()) { selectStatement.getLimitClause().accept(this, arg); } return null; }
@Override public Expression visit(LimitClause limitClause, ILangExpression arg) throws CompilationException { limitClause.setLimitExpr(visit(limitClause.getLimitExpr(), limitClause)); if (limitClause.hasOffset()) { limitClause.setOffset(visit(limitClause.getOffset(), limitClause)); } return null; }
@Override public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(LimitClause lc, VariableSubstitutionEnvironment env) throws CompilationException { Pair<ILangExpression, VariableSubstitutionEnvironment> p1 = lc.getLimitExpr().accept(this, env); Pair<ILangExpression, VariableSubstitutionEnvironment> p2; Expression lcOffsetExpr = lc.getOffset(); if (lcOffsetExpr != null) { p2 = lcOffsetExpr.accept(this, env); } else { p2 = new Pair<>(null, null); } LimitClause c = new LimitClause((Expression) p1.first, (Expression) p2.first); c.setSourceLocation(lc.getSourceLocation()); return new Pair<>(c, env); }
final public LimitClause LimitClause() throws ParseException, ParseException { Token startToken = null; LimitClause lc = new LimitClause(); Expression expr; pushForbiddenScope(getCurrentScope()); jj_consume_token(LIMIT); startToken = token; expr = Expression(); lc.setLimitExpr(expr); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case OFFSET: jj_consume_token(OFFSET); expr = Expression(); lc.setOffset(expr); break; default: jj_la1[190] = jj_gen; ; } popForbiddenScope(); {if (true) return addSourceLocation(lc, startToken);} throw new Error("Missing return statement in function"); }
@Override public Boolean visit(LimitClause lc, ILangExpression arg) throws CompilationException { return visit(lc.getLimitExpr(), arg) || visit(lc.getOffset(), arg); }
selectExpression.getLimitClause().accept(visitor, arg);
@Override public Boolean visit(LimitClause lc, List<FunctionDecl> arg) throws CompilationException { Pair<Boolean, Expression> p1 = inlineUdfsInExpr(lc.getLimitExpr(), arg); lc.setLimitExpr(p1.second); boolean changed = p1.first; if (lc.getOffset() != null) { Pair<Boolean, Expression> p2 = inlineUdfsInExpr(lc.getOffset(), arg); lc.setOffset(p2.second); changed = changed || p2.first; } return changed; }
@Override public Void visit(LimitClause lc, Integer step) throws CompilationException { out.print(skip(step) + "limit "); lc.getLimitExpr().accept(this, step + 1); if (lc.getOffset() != null) { out.print(" offset "); lc.getOffset().accept(this, step + 1); } out.println(); return null; }
@Override public Void visit(SelectExpression selectStatement, Integer step) throws CompilationException { if (selectStatement.isSubquery()) { out.print("("); } int selectStep = selectStatement.isSubquery() ? step + 2 : step; if (selectStatement.hasLetClauses()) { for (LetClause letClause : selectStatement.getLetList()) { letClause.accept(this, selectStep); } } selectStatement.getSelectSetOperation().accept(this, selectStep); if (selectStatement.hasOrderby()) { selectStatement.getOrderbyClause().accept(this, selectStep); } if (selectStatement.hasLimit()) { selectStatement.getLimitClause().accept(this, selectStep); } if (selectStatement.isSubquery()) { out.print(skip(step) + " )"); } return null; }
@Override public Expression visit(LimitClause limitClause, ILangExpression arg) throws CompilationException { scopeChecker.pushForbiddenScope(scopeChecker.getCurrentScope()); limitClause.setLimitExpr(visit(limitClause.getLimitExpr(), limitClause)); if (limitClause.hasOffset()) { limitClause.setOffset(visit(limitClause.getOffset(), limitClause)); } scopeChecker.popForbiddenScope(); return null; }
@Override public Void visit(LimitClause lc, Integer step) throws CompilationException { out.println(skip(step) + "Limit"); lc.getLimitExpr().accept(this, step + 1); if (lc.getOffset() != null) { out.println(skip(step + 1) + "Offset"); lc.getOffset().accept(this, step + 2); } return null; }