impala-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex Behm (Code Review)" <>
Subject [Impala-ASF-CR] IMPALA-4731: Crash when sorting on non-deterministic expr
Date Wed, 08 Feb 2017 23:37:18 GMT
Alex Behm has posted comments on this change.

Change subject: IMPALA-4731: Crash when sorting on non-deterministic expr

Patch Set 2:

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

Line 173:     ExprSubstitutionMap substOrderBy = new ExprSubstitutionMap();
It's important to update this smap according to the new materialization you are doing below.
I'd prefer to keep the original flow where we populate this smap and then substituteOrderingExprs().

For example, one case that I believe will not work as expected is:

select rand() r from t order by r

The reason is that we will not substitute the rand() from the select list with the materialized
slot produced in the order by - but we should. Similar arguments apply for something like:

select my_expensive_expr() e from t order by e

We will redundantly evaluate my_expensive_expr in the select list again.

Line 186:     // TODO: it may be better for performance to not materialize some exprs that
I think we should address this TODO while we are here.

We should materialize:
1. All known non-deterministic functions.
We can add an Expr.isDeterministic() function and implement that for FunctionCallExpr like
we implement isConstant().

2. All UDFs. We can check whether an Expr is a UDF.

3. Exprs that are 'expensive' according to some cost threshold. If the cost is unknown, I'd
say materialize.

To view, visit
To unsubscribe, visit

Gerrit-MessageType: comment
Gerrit-Change-Id: I5dcda32fc7770d42fc500ce87fc54d58e5b5dc00
Gerrit-PatchSet: 2
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Owner: Thomas Tauber-Marshall <>
Gerrit-Reviewer: Alex Behm <>
Gerrit-Reviewer: Thomas Tauber-Marshall <>
Gerrit-Reviewer: Tim Armstrong <>
Gerrit-HasComments: Yes

View raw message