May be James.. I will send you what I have done.. Infact I have done the same but it has problems..

From: James Taylor [mailto:notifications@github.com]
Sent: Thursday, January 23, 2014 10:56 PM
To: forcedotcom/phoenix
Cc: Vasudevan, Ramkrishna S
Subject: Re: [phoenix] Upsert Values and Upsert Select with Array (#707)


In phoenix-core/src/main/java/com/salesforce/phoenix/compile/ExpressionCompiler.java:

> @@ -1289,4 +1292,45 @@ public Expression visit(SequenceOpParseNode node)

>          .setSchemaName(node.getTableName().getSchemaName())

>          .setTableName(node.getTableName().getTableName()).build().buildException();

>       }

> +

> +     @Override

> +     public Expression visitLeave(ArrayConstructorNode node, List<Expression> children)

> +                    throws SQLException {

> +            ArrayConstructorExpression arrayExpression = new ArrayConstructorExpression(

You'll have a loop in your evaluate method (look at other evaluate methods as a guide). Everything is an expression that you can evaluate (doesn't matter if it's a literal or any other expression. During evaluate, you have the Tuple which is used by column expression to look up the actual value. It'll look something like this:

List<Expression> children = getChildren();

int nChildren = children.size();

for (int i = 0; i < nChildren; i++) {

    Expression child = children.get(i);

    if (!child.evaluate(tuple, ptr)) { // Can't evaluate, so return false

        return false;

    }

    Object o = getDataType().toObject(ptr, child.getDataType(), child.getColumnModifier());

    // Add to list of objects used to create array after end of for loop

}

—
Reply to this email directly or view it on GitHub<https://github.com/forcedotcom/phoenix/pull/707/files#r9120839>.