Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
Impala 3.0
-
None
-
None
-
ghx-label-9
Description
A SELECT statement has three independent copies of the SELECT list expressions:
- The SELECT list itself, as provided by the parser
- The result expressions, which represents the output tuple
- The Base table result expressions, maintained by the QueryStmt
When using a constant expression, the base table list is out of sync with the other two:
String query = "SELECT 1 + 1 AS c" + " from functional.alltypestiny"; AnalysisContext ctx = createAnalysisCtx(); ctx.getQueryOptions().setEnable_expr_rewrites(true); SelectStmt select = (SelectStmt) AnalyzesOk(query, ctx); Expr selectExpr = select.getSelectList().getItems().get(0).getExpr(); assertEquals(ScalarType.SMALLINT, selectExpr.getType()); Expr resultExpr = select.getResultExprs().get(0); assertEquals(ScalarType.SMALLINT, resultExpr.getType()); Expr baseTableExpr = select.getBaseTblResultExprs().get(0); // Fails assertEquals(ScalarType.SMALLINT, baseTableExpr.getType());
The last assertion above fails with:
Expected: SMALLINT but was: TINYINT
This error does not occur if rewrites are disabled:
ctx.getQueryOptions().setEnable_expr_rewrites(false);
It is not clear if the BE needs the information that is incorrect. But, to reduce cognitive load on developers, things should be consistent.