Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions fe/src/com/baidu/palo/analysis/LimitElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ public String toSql() {
sb.append("" + limit);
return sb.toString();
}

public void analyze(Analyzer analyzer) {
if (limit == 0) analyzer.setHasEmptyResultSet();
}

public void reset() {
limit = -1;
offset = 0;
}
}
11 changes: 10 additions & 1 deletion fe/src/com/baidu/palo/analysis/QueryStmt.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,19 @@ public abstract class QueryStmt extends StatementBase {
public void analyze(Analyzer analyzer) throws AnalysisException, InternalException {
if (isAnalyzed()) return;
super.analyze(analyzer);
// analyzeLimit(analyzer);
analyzeLimit(analyzer);
if (hasWithClause()) withClause_.analyze(analyzer);
}

private void analyzeLimit(Analyzer analyzer) throws AnalysisException {
// TODO chenhao
if (limitElement.getOffset() > 0 && !hasOrderByClause()) {
throw new AnalysisException("OFFSET requires an ORDER BY clause: " +
limitElement.toSql().trim());
}
limitElement.analyze(analyzer);
}

/**
* Returns a list containing all the materialized tuple ids that this stmt is
* correlated with (i.e., those tuple ids from outer query blocks that TableRefs
Expand Down
2 changes: 1 addition & 1 deletion fe/src/com/baidu/palo/analysis/SelectStmt.java
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public void materializeRequiredSlots(Analyzer analyzer) throws AnalysisException
// can also be safely evaluated below the join (picked up by getBoundPredicates()).
// Such predicates will be marked twice and that is ok.
List<Expr> unassigned =
analyzer.getUnassignedConjuncts(getTableRefIds());
analyzer.getUnassignedConjuncts(getTableRefIds(), true);
List<Expr> unassignedJoinConjuncts = Lists.newArrayList();
for (Expr e: unassigned) {
if (analyzer.evalByJoin(e)) {
Expand Down