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

Better error reporting for unsupported case like max(x)-min(y) #286

Merged
merged 3 commits into from
Nov 15, 2019
Merged

Better error reporting for unsupported case like max(x)-min(y) #286

merged 3 commits into from
Nov 15, 2019

Conversation

galkk
Copy link
Contributor

@galkk galkk commented Nov 15, 2019

Issue #, if available: #194, #234

Description of changes:
Better error reporting for such queries

POST /_opendistro/_sql/_explain
{
  "query":"""SELECT DestCountry, dayOfWeek, max(FlightDelayMin) - min(FlightDelayMin) + avg(FlightDelayMin)
    FROM kibana_sample_data_flights
    GROUP BY DestCountry, dayOfWeek
  """

returns now

{
  "error": {
    "reason": "There was internal problem at backend",
    "details": "The complex aggregate expressions are not implemented yet: MAX(FlightDelayMin) - MIN(FlightDelayMin)",
    "type": "SqlFeatureNotImplementedException"
  },
  "status": 503
}

instead of non-sensical:

{
  "error": {
    "reason": "Invalid SQL query",
    "details": "",
    "type": "NullPointerException"
  },
  "status": 400
}

and another example:

                        "SELECT DestCountry, dayOfWeek, log(max(FlightDelayMin))" +
                        "   FROM kibana_sample_data_flights\n" +
                        "   GROUP BY DestCountry, dayOfWeek\n"));
```

witll throw

                  "Function calls of form 'log(MAX(...))' are not implemented yet");


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@chloe-zh
Copy link
Member

I think the code changes for now covers more than cases like max(x) - min(y). It seems the object is always the left one of a binary operation, so it can cover the cases as long as it looks like max(x) + y. Could you implement the cases of x + min(y)-like in this PR as well?

@galkk
Copy link
Contributor Author

galkk commented Nov 15, 2019

@chloe-zh

The case that you've mentioned already works

POST /_opendistro/_sql/_explain
{
  "query":"""SELECT 1+max(FlightDelayMin)
    FROM kibana_sample_data_flights
    GROUP BY DestCountry, dayOfWeek
  """
}


{
  "error": {
    "reason": "There was internal problem at backend",
    "details": "The complex aggregate expressions are not implemented yet: 1 + MAX(FlightDelayMin)",
    "type": "SqlFeatureNotImplementedException"
  },
  "status": 503
}

Copy link
Member

@chloe-zh chloe-zh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@galkk galkk merged commit e0f8702 into opendistro-for-elasticsearch:master Nov 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants