druid icon indicating copy to clipboard operation
druid copied to clipboard

Malformed GroupBy JSON Query Returns a 500

Open scot0357 opened this issue 9 years ago • 1 comments

Submitting GroupBy queries to the JSON query API returns a 500 when given duplicate output name columns. For example:

{
    "context": {"queryId": "010b5fa5-9a45-4614-8c0b-acaa747c2af0"},
    "dataSource": "Famous_Duets",
    "aggregations": [{
        "fieldName": "count",
        "name": "count",
        "type": "count"
    }],
    "dataSource": "my_datasource",
    "dimensions": [{
        "dimension": "Female_Singer",
        "outputName": "Singer",
        "type": "default"
    }, {
        "dimension": "Male_Singer",
        "outputName": "Singer",
        "type": "default"
    }],
    "granularity": "all",
    "intervals": ["2017-06-20T14:51:00Z/2017-06-20T18:27:00Z"],
    "queryType": "groupBy"
}

Note that Singer is the outputName for more than one groupBy dimension. The query response is:

{"error":"Unknown exception"}

Obviously, the query is malformed, but returning the error in this response might be helpful. The way I tracked it down was in the logs:

2017-06-20T18:49:09,604 INFO [qtp1665324560-197[groupBy_Famous_Duets_010b5fa5-9a45-4614-8c0b-acaa747c2af0]] io.druid.server.QueryResource - Unknown exception [010b5fa5-9a45-4614-8c0b-acaa747c2af0]

Later in the logs, a log containing:

Dimension[Singer] occurred more than once in InputRow

Tipped me off to what the error was.

scot0357 avatar Jun 20 '17 19:06 scot0357

Thanks for the report @scot0357. This should fail-fast with a better message in 0.10.0+, thanks to #3686. If you still see this sort of poor behavior with 0.10.0+ then please let us know.

gianm avatar Jun 20 '17 19:06 gianm