Author: Alex Behm <email@example.com>
Date: Fri Oct 14 11:19:39 2016 -0700
IMPALA-4309: Introduce Expr rewrite phase and supporting classes.
Introduces a new phase for rewriting Exprs after analysis and
before subquery rewriting. The transformed Exprs replace the
original ones in analyzed statements. If Exprs were changed,
the whole statement is reset() and re-analyzed, similar to how
subqueries are rewritten. If both Exprs and subqueries are
rewritten there is only one re-analysis of the changed statement.
The following new classes work together to perform transformations:
- base class for Expr transformation rules
- drives the transformation of Exprs using a list of
Statements that have exprs to be rewritten need to implement
a new method rewriteExprs() that accepts an ExprRewriter.
As an example, this patch adds a rule for converting
BetweenPredicates into their equivalent CompoundPredicates.
The BetweenPredicate has been notoriously buggy due to a lack
of such a separate rewrite phase and is now cleaned up.
1. Added a new test for checking that the rewrite framework
covers all relevant statements, clauses and can properly
handle nested statements and subqueries.
2. Added a new test for ExprRewriteRules and implemented
tests for the BetweenPredicate rewrite.
2. There are many existing tests for BetweePredicates and
they all exercise the new rewrite rule/phase.
3. Ran a private core/hdfs run and it passed.
Reviewed-by: Alex Behm <firstname.lastname@example.org>
Tested-by: Internal Jenkins