[
https://issues.apache.org/jira/browse/PHOENIX-2160?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14716951#comment-14716951
]
James Taylor commented on PHOENIX-2160:
---------------------------------------
Thanks for the revisions, [~Dumindux]. Getting close, but a few more issues:
- The ReplaceArrayFunctionExpressionVisitor. isCloneNode() method should return
true if the children and the node children are *not* equal. This means that a
child expression further down the tree was replaced, so we have to continue to
replace all the way up the tree.
{code}
+ @Override
+ public boolean isCloneNode(Expression node, List<Expression> children) {
+ return !children.equals(node.getChildren());
+ }
{code}
- Add a test that would have caught the above by using an expression with an
array element reference.
{code}
SELECT arr1[1] + 5, arr2[1] FROM a
{code}
- Add tests where the expression in the select is more complicated, for example
a CASE statement that uses array element references.
- Don't use containsKey and then get the value as you're doing two lookups in
the map when you can get away with one. Just do a get and check for null:
{code}
+ @Override
+ public Expression visitLeave(ScalarFunction node, List<Expression> l) {
+ Expression replacement = replacementMap.get(node);
+ if (replacement != null) {
+ return replacement;
+ }
+ return super.visitLeave(node, l);
+ }
{code}
and here
{code}
+ @Override
+ public Expression visit(ColumnParseNode node) throws SQLException {
+ Expression expression = super.visit(node);
+ if (expression.getDataType().isArrayType())
+ Integer count = arrayExpressionCounts.get(expression);
+ arrayExpressionCounts.put(expression, count == null ? 1 :
(count + 1));
+ }
+ return expression;
+ }
{code}
and a couple other places (just search for containsKey).
- Minor nit: why not just declare these where they're defined?
{code}
+ ValueBitSet arrayIndexesBitSet = null;
+ KeyValueSchema arrayIndexesSchema = null;
{code}
> 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-2160_v5.patch,
> PHOENIX-2160_v6.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)