Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-5965

JSON array index access returns an empty array

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.12.0
    • None
    • Storage - JSON
    • None

    Description

      Accessing an array with [<array-index>] from JSON data, returns an empty string, whereas it should return the actual data from the array at the index and not an empty array.

      Drill 1.11.0-mapr commit: 065d72ba48c7af6b389b763753ecb6bf7d229ce8

      0: jdbc:drill:schema=dfs.tmp> select t.structured_rep[0] from `cornell_nlvr_train.json` t limit 1;
      +---------+
      | EXPR$0  |
      +---------+
      | []      |
      +---------+
      1 row selected (0.249 seconds)
      

      Where as accessing the elements of the array returns correct results.

      0: jdbc:drill:schema=dfs.tmp> select t.structured_rep[0][0] from `cornell_nlvr_train.json` t limit 1;
      +-----------------------------------------------------------------------+
      |                                EXPR$0                                 |
      +-----------------------------------------------------------------------+
      | {"y_loc":21,"size":20,"type":"triangle","x_loc":27,"color":"Yellow"}  |
      +-----------------------------------------------------------------------+
      1 row selected (0.325 seconds)
      0: jdbc:drill:schema=dfs.tmp> select t.structured_rep[0][1] from `cornell_nlvr_train.json` t limit 1;
      +---------------------------------------------------------------------+
      |                               EXPR$0                                |
      +---------------------------------------------------------------------+
      | {"y_loc":60,"size":10,"type":"circle","x_loc":59,"color":"Yellow"}  |
      +---------------------------------------------------------------------+
      1 row selected (0.247 seconds)
      

      Data used in the test

      {
      	"sentence": "There is a circle closely touching a corner of a box.",
      	"label": "true",
      	"identifier": "1304-0",
      	"directory": "74",
      	"evals": {
      		"r0": "true"
      	},
      	"structured_rep": [
      		[{
      			"y_loc": 21,
      			"size": 20,
      			"type": "triangle",
      			"x_loc": 27,
      			"color": "Yellow"
      		}, {
      			"y_loc": 60,
      			"size": 10,
      			"type": "circle",
      			"x_loc": 59,
      			"color": "Yellow"
      		}],
      		[{
      			"y_loc": 81,
      			"size": 10,
      			"type": "triangle",
      			"x_loc": 48,
      			"color": "Yellow"
      		}, {
      			"y_loc": 64,
      			"size": 20,
      			"type": "circle",
      			"x_loc": 77,
      			"color": "#0099ff"
      		}],
      		[{
      			"y_loc": 2,
      			"size": 20,
      			"type": "triangle",
      			"x_loc": 62,
      			"color": "Yellow"
      		}, {
      			"y_loc": 70,
      			"size": 30,
      			"type": "circle",
      			"x_loc": 70,
      			"color": "Black"
      		}, {
      			"y_loc": 51,
      			"size": 20,
      			"type": "circle",
      			"x_loc": 30,
      			"color": "#0099ff"
      		}, {
      			"y_loc": 42,
      			"size": 20,
      			"type": "circle",
      			"x_loc": 67,
      			"color": "Yellow"
      		}, {
      			"y_loc": 73,
      			"size": 20,
      			"type": "circle",
      			"x_loc": 37,
      			"color": "Black"
      		}, {
      			"y_loc": 14,
      			"size": 30,
      			"type": "triangle",
      			"x_loc": 7,
      			"color": "Yellow"
      		}, {
      			"y_loc": 27,
      			"size": 10,
      			"type": "circle",
      			"x_loc": 48,
      			"color": "Black"
      		}]
      	]
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            khfaraaz Khurram Faraaz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: