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

functions do not handle missing value well #144

Closed
galkk opened this issue Aug 8, 2019 · 0 comments
Closed

functions do not handle missing value well #144

galkk opened this issue Aug 8, 2019 · 0 comments
Labels
duplicate This issue or pull request already exists

Comments

@galkk
Copy link
Contributor

galkk commented Aug 8, 2019

Functions do not handle missing value from an document well.

Test data

Based on https://partiql.org/tutorial.html#tuples-with-missing-attributes.

PUT /employess_with_missing/_doc/3?pretty
{
  "name": "Bob Smith"
}

PUT /employess_with_missing/_doc/4?pretty
{
  "name": "Susan Smith", "title": "Dev Mgr", "age": 33
}


PUT /employess_with_missing/_doc/6?pretty
{
  "name": "Jane Smith", "title": "Software Eng 2", "age": 25
}

String funtion trim: error

GET /_opendistro/_sql/_explain
{
  "query": "SELECT e.name, TRIM(e.title) as outputTitle from employess_with_missing"
}

Returns

        "type": "script_exception",
        "reason": "runtime error",
        "script_stack": [
          "org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:94)",
          "org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:41)",
          "trim_1018882869 = doc['e.title'].value.trim();",
          "                      ^---- HERE"
        ],
        "script": "def trim_1018882869 = doc['e.title'].value.trim();return trim_1018882869;",
        "lang": "painless"
      }

Expected result:

  {
    'id': 3,
    'employeeName': 'Bob Smith'
  },
  {
    'id': 4,
    'employeeName': 'Susan Smith',
    'outputTitle': 'Dev Mgr'
  },
  {
    'id': 6,
    'employeeName': 'Jane Smith',
    'outputTitle': 'Software Eng 2'
  }

Numerical function error

GET /_opendistro/_sql
{
  "query": "SELECT e.name from employess_with_missing e WHERE sqrt(age) > 27"
}

Has the same error about missing field, while it should return all names from table

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants