Nick Dimiduk created PHOENIX-2708:
-------------------------------------

             Summary: 0-index array access is erroniously permitted
                 Key: PHOENIX-2708
                 URL: https://issues.apache.org/jira/browse/PHOENIX-2708
             Project: Phoenix
          Issue Type: Bug
            Reporter: Nick Dimiduk
            Priority: Minor
             Fix For: 4.6.0


>From [ARRAY Type|http://phoenix.apache.org/array_type.html], accessing the 
>0-index array entry is not permitted. However, with a VARCHAR ARRAY, the 
>accessor allows it, resulting in surprising empty string and/or nulls handed 
>up to parent expressions. This should instead throw a SQLException.

{noformat}
> select * from test1;
+----+-----------------------+
| A  |           B           |
+----+-----------------------+
| 1  | ['a', 'b', 'c']       |
| 2  | ['w', 'x', 'y', 'z']  |
+----+-----------------------+
2 rows selected (0.451 seconds)
> select a, b[0] from test1;
+----+-------------------+
| A  | ARRAY_ELEM(B, 0)  |
+----+-------------------+
| 1  |                   |
| 2  |                   |
+----+-------------------+
2 rows selected (0.032 seconds)
> select a, length(b[0]) from test1;
+----+---------------------------+
| A  | LENGTH(ARRAY_ELEM(B, 0))  |
+----+---------------------------+
| 1  | null                      |
| 2  | null                      |
+----+---------------------------+
2 rows selected (0.048 seconds)
{noformat}



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

Reply via email to