Skip to content

Commit

Permalink
distinguish limit 0 in analyze (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenhao7253886 authored Mar 12, 2018
1 parent 12d54c7 commit b8fa22d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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

0 comments on commit b8fa22d

Please sign in to comment.