impala-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marcel Kornacker (Code Review)" <>
Subject [Impala-ASF-CR] IMPALA-4309: Introduce Expr rewrite phase and supporting classes.
Date Sat, 22 Oct 2016 19:57:42 GMT
Marcel Kornacker has posted comments on this change.

Change subject: IMPALA-4309: Introduce Expr rewrite phase and supporting classes.

Patch Set 5:

File fe/src/main/java/org/apache/impala/analysis/

Line 355
what was going on with this?

Line 379:         analysisResult_.stmt_.rewriteExprs(rewriter_);
for the between transformation it's not necessary, but in general i'd expect to do this repeatedly
until nothing changes, no?
File fe/src/main/java/org/apache/impala/analysis/

Line 56:           "supported in a between predicate: " + toSqlImpl());
capitalize between
File fe/src/main/java/org/apache/impala/analysis/

Line 59:   protected Expr havingClause_;  // original having clause
why move it?

Line 874:       // Also rewrite exprs in the statements of subqueries.
the problem you have is that the parent/child expr tree doesn't give you access to all exprs
in the tree.

instead of hardwiring this logic here and there, how about introducing a Expr.getContainedExprs()
(or some other name) which returns the children and all other contained exprs.

another approach would be to make SelectStmts exprs (and the where/having/group by clauses
would be children), but that seems fairly involved.
File fe/src/main/java/org/apache/impala/analysis/

Line 69
File fe/src/main/java/org/apache/impala/rewrite/

Line 38:     numChanges_ = 0;
should rules really have state?

why can't the driver take care of tracking the changes and do the recursive application of
rules, and the rule itself would only apply to a single Expr (and not its children)? that
would also be far better if we have rules that require more complicated interleaving, otherwise
the rules would need to know about each other. see my comments on the rewriter.

Line 46:     if (expr instanceof BetweenPredicate) {
if (!(expr instanceof ...)) return expr;
File fe/src/main/java/org/apache/impala/rewrite/

Line 40:   public abstract Expr rewrite(Expr expr, Analyzer analyzer) throws AnalysisException;
call it apply then?
File fe/src/main/java/org/apache/impala/rewrite/

Line 31: public class ExprRewriter extends ExprRewriteRule {
what's the point of making it a subclass of ExprRewriteRule?

if this is the driver class, it should have the list of rules as well. also, in the future
we might have rules that require repeated and/or interleaved application (think llvm optimization
phases), and this driver class could then encapsulate the knowledge about correct ordering,
File fe/src/test/java/org/apache/impala/common/

Line 186:     // Do not analyze the stmt to avoid applying rewrites.
why is that bad?

To view, visit
To unsubscribe, visit

Gerrit-MessageType: comment
Gerrit-Change-Id: I2279dc984bcf7742db4fa3b1aa67283ecbb05e6e
Gerrit-PatchSet: 5
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Owner: Alex Behm <>
Gerrit-Reviewer: Alex Behm <>
Gerrit-Reviewer: Bharath Vissapragada <>
Gerrit-Reviewer: Dimitris Tsirogiannis <>
Gerrit-Reviewer: Marcel Kornacker <>
Gerrit-Reviewer: Tim Armstrong <>
Gerrit-HasComments: Yes

View raw message