Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-2708

0-index array access is erroniously permitted

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • 4.6.0
    • None
    • None

    Description

      From ARRAY Type, 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.

      > 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)
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            ndimiduk Nick Dimiduk
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: