Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL: return more understandable error when not grouping by a histogram #37952

Closed
eskibars opened this issue Jan 29, 2019 · 2 comments
Closed

Comments

@eskibars
Copy link
Contributor

Testing on 6.6.0.

Consider using SQL to query for a 1-minute histogram, e.g. across a default metricbeat index (and the default time field, @timestamp).

GET /_xpack/sql?format=txt
{
  "query": """
  SELECT HISTOGRAM("@timestamp", INTERVAL 1 MINUTE) AS h FROM "metricbeat-*" GROUP BY h
  """
}

This correctly returns. However, when omitting GROUP BY ... as in:

GET /_xpack/sql?format=txt
{
  "query": """
  SELECT HISTOGRAM("@timestamp", INTERVAL 1 MINUTE) FROM "metricbeat-*"
  """
}

We get:

{
  "error": {
    "root_cause": [
      {
        "type": "sql_illegal_argument_exception",
        "reason": "Unknown output attribute HISTOGRAM(@timestamp){g->2644358}#2644358"
      }
    ],
    "type": "sql_illegal_argument_exception",
    "reason": "Unknown output attribute HISTOGRAM(@timestamp){g->2644358}#2644358"
  },
  "status": 500
}

We should clean up the error here so it's easier for a user to understand what they've done wrong.

@colings86 colings86 added the :Analytics/SQL SQL querying label Jan 29, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@astefan
Copy link
Contributor

astefan commented Feb 4, 2019

master(7.0.0): 6968f09
6.x (6.7.0): 4cf0391
6.6 (6.6.1): d05c24c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants