MCPcopy Create free account
hub / github.com/apache/impala / evalToInteger

Method evalToInteger

fe/src/main/java/org/apache/impala/analysis/Expr.java:1912–1941  ·  view source on GitHub ↗

Analyzes and evaluates expression to an integral value, returned as a long. Throws if the expression cannot be evaluated or if the value evaluates to null. The 'name' parameter is used in exception messages, e.g. "LIMIT expression evaluates to NULL". If 'acceptDate' is true, treat Date expression as

(Analyzer analyzer, String name, boolean acceptDate)

Source from the content-addressed store, hash-verified

1910 * expression as well.
1911 */
1912 public long evalToInteger(Analyzer analyzer, String name, boolean acceptDate)
1913 throws AnalysisException {
1914 // Check for slotrefs and subqueries before analysis so we can provide a more
1915 // helpful error message.
1916 if (contains(SlotRef.class) || contains(Subquery.class)) {
1917 throw new AnalysisException(name + " expression must be a constant expression: " +
1918 toSql());
1919 }
1920 analyze(analyzer);
1921 if (!isConstant()) {
1922 throw new AnalysisException(name + " expression must be a constant expression: " +
1923 toSql());
1924 }
1925 if (!getType().isIntegerType() && !(acceptDate && getType().isDate())) {
1926 throw new AnalysisException(name + " expression must be an integer type but is '" +
1927 getType() + "': " + toSql());
1928 }
1929 TColumnValue val = null;
1930 try {
1931 val = FeSupport.EvalExprWithoutRow(this, analyzer.getQueryCtx());
1932 } catch (InternalException e) {
1933 throw new AnalysisException("Failed to evaluate expr: " + toSql(), e);
1934 }
1935
1936 try {
1937 return evalToInteger(val, acceptDate);
1938 } catch (AnalysisException e) {
1939 throw new AnalysisException(name + " expression evaluates to NULL: " + toSql());
1940 }
1941 }
1942
1943 public static long evalToInteger(TColumnValue val, boolean acceptDate)
1944 throws AnalysisException {

Callers 5

analyzeVersionBasedMethod · 0.80
analyzeParameterMethod · 0.80

Calls 9

toSqlMethod · 0.95
analyzeMethod · 0.95
isConstantMethod · 0.95
getTypeMethod · 0.95
EvalExprWithoutRowMethod · 0.95
isIntegerTypeMethod · 0.80
isDateMethod · 0.80
containsMethod · 0.45
getQueryCtxMethod · 0.45

Tested by

no test coverage detected