You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by "James Taylor (JIRA)" <ji...@apache.org> on 2016/11/17 00:04:59 UTC

[jira] [Created] (PHOENIX-3489) Compile out expressions formed by only columns with WHERE clause equality constraints in GROUP BY and ORDER BY

James Taylor created PHOENIX-3489:
-------------------------------------

             Summary: Compile out expressions formed by only columns with WHERE clause equality constraints in GROUP BY and ORDER BY
                 Key: PHOENIX-3489
                 URL: https://issues.apache.org/jira/browse/PHOENIX-3489
             Project: Phoenix
          Issue Type: Bug
            Reporter: James Taylor


Since columns constrained by equality constraints evaluate to the same constant value, expressions formed only by them may be stripped out of GROUP BY and ORDER BY clauses.

For example, the group by key for this query can be only pk2:
{code}
SELECT FLOOR(pk1), pk2 FROM t WHERE pk1 = 1 
GROUP BY FLOOR(pk1), pk2
{code}
This can be implemented by
- using OrderPreservingTracker.IsConstantVisitor to detect this case
- evaluating the expression at compilation time
- storing the resulting LiteralExpression as the leading group by expressions
- storing the count of constant expressions in GroupBy as constantGroupByCount
- modifying ExpressionCompiler.wrapGroupByExpression() to return the LiteralExpression when the position is less that the constantGroupByCount
- sending to the server only non constants in the GroupBy.keyExpressions list

For ORDER BY, we can simply remove these expressions from the OrderBy.orderByExpressions lists. A further optimization would be to not even project the constant ORDER BY expression and transform it into a literal on the client side.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)