IMPALA-4716: Expr rewrite causes IllegalStateException

The DECODE constructor in CaseExpr uses the same decodeExpr object when
building the BinaryPredicates that compare the decodeExpr to each 'when'
of the DECODE. This causes problems when different BinaryPredicates try
to cast the same decodeExpr object to different types during analysis,
in this case leading to a Precondition check failure.

The solution is to clone the decodeExpr in the DECODE constructor in
CaseExpr for each generated BinaryPredicate.

Testing:
- Added a regression test to exprs.test

Change-Id: I4de9ed7118c8d18ec3f02ff74c9cca211c716e51
Reviewed-on: http://gerrit.cloudera.org:8080/5631
Reviewed-by: Marcel Kornacker <marcel@cloudera.com>
Tested-by: Impala Public Jenkins
This commit is contained in:
Thomas Tauber-Marshall
2017-01-05 16:15:32 -08:00
committed by Impala Public Jenkins
parent c4f2458e39
commit 89a3d3c1eb
3 changed files with 35 additions and 4 deletions

View File

@@ -2649,3 +2649,19 @@ select count(*) from functional.alltypestiny group by concat(uuid(), "_test")
---- TYPES
BIGINT
====
---- QUERY
# IMPALA-4716: Tests that decode with 'when' values of different types is analyzed
# correctly when expr rewrites are enabled.
select decode(0, 1, 0, id, 1, 2) a from functional.alltypestiny order by a
---- RESULTS
1
2
2
2
2
2
2
2
---- TYPES
TINYINT
====