Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

distinguish limit 0 in analyze #186

Merged
merged 1 commit into from
Mar 12, 2018
Merged
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