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

James Taylor commented on PHOENIX-2160:
---------------------------------------

Good catch, [~Dumindux]. We'll need to catch this case in ProjectionCompiler 
and turn off the optimization if the entire array is referenced. The reason is 
that since we need to return the entire array anyway, the optimization won't 
help (it'll actually make it slightly worse by unnecessarily adding the payload 
sent back). The tricky part will be detecting when the array is referenced, but 
it's not a call to ArrayIndexFunction.

To detect this, I think you'd need to modify 
SelectClauseVisitor.resolveColumn() to track when ref.getColumn() is of type 
array. I think you need to count references, because array element dereferences 
(ArrayIndexFunction) would also come through this code path. Something like a 
Map<Expression,Integer>. Each call to SelectClauseVisitor.resolveColumn()  
would increment the Integer and each call to visitLeave(FunctionParseNode 
node), when it's an ArrayIndexFunction would decrement it (looking it up via 
the Expression that is of type array). Then in top level compile call, before 
the selectVisitor.reset() call, you'd need to make one pass through the 
arrayKVFuncs and remove any elements (both from arrayKVFuncs and arrayKVRefs) 
if you find a reference count > 0 in your Map<Expression,Integer>.


> Projection of specific array index does not work
> ------------------------------------------------
>
>                 Key: PHOENIX-2160
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-2160
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: ramkrishna.s.vasudevan
>            Assignee: ramkrishna.s.vasudevan
>         Attachments: PHOENIX-2160.patch, PHOENIX-2160_v2.patch, 
> PHOENIX-2160_v3.patch, PHOENIX-2160_v4.patch
>
>
> PHOENIX-10 that allowed projection of specific array index does not work now. 
> Was looking into the code for some thing and found this issue. Let me know if 
> am missing something.



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

Reply via email to