Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

When using * in select, myIndex.field.subFieldA > myIndex.field.subFieldB fails #1055

Open
FreCap opened this issue Feb 21, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@FreCap
Copy link
Contributor

FreCap commented Feb 21, 2021

Thank @penghuo for the #795 fix!

a follow up on this.

When using * in a subfield (non-nested), breaks



POST my_test_ndex/_doc/
{
  "field1": {
    "subFieldA": 1,
    "subFieldB": 2
  },
  "field2": {
    "subFieldA": 1,
    "subFieldB": 2
  }
}

// Exception
POST _opendistro/_sql
{
  "query": """SELECT field2.* FROM
  my_test_ndex as i 
  WHERE 
  i.field1.subFieldA <i.field1.subFieldB
    LIMIT 50;"""
}

---->>

{
  "error": {
    "reason": "Error occurred in Elasticsearch engine: all shards failed",
    "details": """Shard[0]: ScriptException[runtime error]; nested: IllegalArgumentException[No field found for [subFieldA] in mapping with types []];

For more details, please send request for Json format to see the raw response from elasticsearch engine.""",
    "type": "SearchPhaseExecutionException"
  },
  "status": 400
}
// Exception
POST _opendistro/_sql
{
  "query": """SELECT field1.* FROM
  my_test_ndex as i 
  WHERE 
  i.field1.subFieldA <i.field1.subFieldB
    LIMIT 50;"""
}
 
------->>
{
  "error": {
    "reason": "Error occurred in Elasticsearch engine: all shards failed",
    "details": """Shard[0]: ScriptException[runtime error]; nested: IllegalArgumentException[No field found for [subFieldA] in mapping with types []];

For more details, please send request for Json format to see the raw response from elasticsearch engine.""",
    "type": "SearchPhaseExecutionException"
  },
  "status": 400
}

These instead work:

POST _opendistro/_sql
{
  "query": """SELECT * FROM
  my_test_ndex as i 
  WHERE 
  i.field1.subFieldA <i.field1.subFieldB
    LIMIT 50;"""
}

POST _opendistro/_sql
{
  "query": """SELECT field1 FROM
  my_test_ndex as i 
  WHERE 
  i.field1.subFieldA <i.field1.subFieldB
    LIMIT 50;"""
}

POST _opendistro/_sql
{
  "query": """SELECT field2 FROM
  my_test_ndex as i 
  WHERE 
  i.field1.subFieldA <i.field1.subFieldB
    LIMIT 50;"""
}

@FreCap FreCap changed the title When using * in select, myIndex.field.subFieldA > myIndex.field.subFieldB generates the wrong painless (doc['subFieldA'].value > doc['subFieldB'].value) When using * in select, myIndex.field.subFieldA > myIndex.field.subFieldB fails Feb 21, 2021
@penghuo
Copy link
Contributor

penghuo commented Feb 22, 2021

Thanks for reporting the issue. Checking now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants