sql icon indicating copy to clipboard operation
sql copied to clipboard

Better document limitation on Array support.

Open penghuo opened this issue 3 years ago • 4 comments

Is your feature request related to a problem? Please describe. Document current limitation on Array support. https://github.com/opensearch-project/sql/blob/main/opensearch/src/main/java/org/opensearch/sql/opensearch/data/utils/OpenSearchJsonContent.java#L132

penghuo avatar Feb 21 '22 22:02 penghuo

Similar issue. #235

penghuo avatar Feb 21 '22 22:02 penghuo

@penghuo Adding one example for documentation. SQL plugin doesn't support arrays and array of objects. It returns just the first element for the both types.

Indexed Doc

PUT my-index-000001/_doc/1
{
  "message": "some arrays in this document...",
  "tags":  [ "opensearch", "wow" ], 
  "lists": [ 
    {
      "name": "prog_list",
      "description": "programming list"
    },
    {
      "name": "cool_list",
      "description": "cool stuff list"
    }
  ]
}

SQL Query, Response

select * from my-index-000001

{
  "schema": [
    {
      "name": "message",
      "type": "text"
    },
    {
      "name": "lists",
      "type": "object"
    },
    {
      "name": "tags",
      "type": "text"
    }
  ],
  "datarows": [
    [
      "some arrays in this document...",
      {
        "name": "prog_list",
        "description": "programming list"
      },
      "opensearch"
    ]
  ],
  "total": 1,
  "size": 1,
  "status": 200
}

ps48 avatar Apr 19 '22 14:04 ps48

Just for reference: Presto/Trino supports array type by asking user to specific it in index mapping: https://trino.io/docs/current/connector/elasticsearch.html#array-types

dai-chen avatar Sep 13 '22 23:09 dai-chen

https://github.com/opensearch-project/sql/blob/b244f2e477476567ae70c139550abaa62316a251/core/src/main/java/org/opensearch/sql/analysis/ExpressionAnalyzer.java#L322-L333

Yury-Fridlyand avatar Oct 05 '22 03:10 Yury-Fridlyand