[ 
https://issues.apache.org/jira/browse/PHOENIX-1030?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14134758#comment-14134758
 ] 

James Taylor commented on PHOENIX-1030:
---------------------------------------

Thanks for the patch, [~tdsilva]. Here's some feedback:
- Instead of DeterministicEnum and getDeterministicEnum(), how about 
Determinism and getDeterminism()?
- You'll need to add a method on Determinism that combines it with another 
Determinism:
{code}
    public Determinism combine(Determinism that) {
        // Always take the biggest Determinism when combining
        return Determinism.values()[Math.max(this.ordinal(), that.ordinal())];
    }
{code}
- In the code that was and-ing together isDeterministic(), consistently call 
the combine method. I noticed you were doing this sometimes inline, but 
sometimes not. This is essentially what propagates the determinism up the 
expression tree. For example, for the expression CURRENT_DATE() - 1 the 
SubtractExpression would become PER_STATEMENT based on propagating up the 
determinism for CURRENT_DATE(). Here's an example of the code I'm referring to:
{code}
@@ -1009,10 +1005,8 @@ public class ExpressionCompiler extends 
UnsupportedAllParseNodeVisitor<Expressio
             @Override
             public Expression create(ArithmeticParseNode node, 
List<Expression> children) throws SQLException {
                 PDataType theType = null;
-                boolean isDeterministic = true;
                 for(int i = 0; i < children.size(); i++) {
                     Expression e = children.get(i);
-                    isDeterministic &= e.isDeterministic();
                     PDataType type = e.getDataType();
                     if (type == null) {
                         continue;
@@ -1038,7 +1032,7 @@ public class ExpressionCompiler extends 
UnsupportedAllParseNodeVisitor<Expressio
                 case DOUBLE:
                     return new DoubleDivideExpression(children);
                 default:
-                    return LiteralExpression.newConstant(null, theType, 
isDeterministic);
+                    return LiteralExpression.newConstant(null, null, 
DeterministicEnum.ALWAYS);
                 }
             }
         });
{code}

> Change Expression.isDeterministic() to return an ENUM with three values 
> {DETERMINISTIC, UNDETERMINISTIC_ROW, UNDETERMINISTIC_STMT}
> ----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: PHOENIX-1030
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1030
>             Project: Phoenix
>          Issue Type: Improvement
>            Reporter: Thomas D'Silva
>            Assignee: Thomas D'Silva
>         Attachments: PHOENIX-1030-3.0.patch, PHOENIX-1030-master.patch
>
>
> Change Expression.isDeterministic() to return an ENUM with three values
> DETERMINISTIC -  the expression returns the same output every time given the 
> same input.
> UNDETERMINISTIC_ROW - the expression should be computed for every row
> UNDETERMINISTIC_STMT - the expression should be be computed for a given 
> statement only once
> See PHOENIX-1001



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

Reply via email to