15 package com.cloudera.impala.analysis;
20 import com.cloudera.impala.thrift.TColumnValue;
21 import com.google.common.base.Preconditions;
39 this.limitExpr_ = limitExpr;
40 this.offsetExpr_ = offsetExpr;
84 StringBuilder sb =
new StringBuilder();
87 sb.append(limitExpr_.toSql());
92 sb.append(
" OFFSET ");
93 sb.append(offsetExpr_.toSql());
106 limitExpr_.analyze(analyzer);
108 throw new AnalysisException(
"LIMIT expression must be an integer type but is '" +
113 if (
limit_ == 0) analyzer.setHasEmptyResultSet();
117 throw new AnalysisException(
"OFFSET expression must be a constant expression: " +
121 offsetExpr_.analyze(analyzer);
138 TColumnValue val = null;
140 val = FeSupport.EvalConstExpr(expr, analyzer.getQueryCtx());
145 if (val.isSetLong_val()) {
146 value = val.getLong_val();
147 }
else if (val.isSetInt_val()) {
148 value = val.getInt_val();
149 }
else if (val.isSetShort_val()) {
150 value = val.getShort_val();
151 }
else if (val.isSetByte_val()) {
152 value = val.getByte_val();
159 expr.toSql() +
" = " + value);
LimitElement(Expr limitExpr, Expr offsetExpr)
LimitElement(LimitElement other)
static long evalIntegerExpr(Analyzer analyzer, Expr expr, String name)
void analyze(Analyzer analyzer)