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

Wrong order when ordering by StringLast agg with GroupBy V2 #7691

Open
jon-wei opened this issue May 17, 2019 · 0 comments
Open

Wrong order when ordering by StringLast agg with GroupBy V2 #7691

jon-wei opened this issue May 17, 2019 · 0 comments

Comments

@jon-wei
Copy link
Contributor

jon-wei commented May 17, 2019

Affected Version

0.13.0+

Description

A user on the mailing list reported the following issue: https://groups.google.com/d/msg/druid-user/x0xuqSFM794/C8tn3J4eDAAJ

The following data, index task, and queries can be used to reproduce the described issue:

data

{"time":"2015-09-12T00:46:58.771Z", "personId":"1111", "name":"ZZZZZ", "age": 30}
{"time":"2015-09-12T01:46:58.771Z", "personId":"1111", "name":"BBBBB", "age": 31}
{"time":"2015-09-12T02:46:58.771Z", "personId":"2222", "name":"YYYYY", "age": 20}
{"time":"2015-09-12T03:46:58.771Z", "personId":"2222", "name":"AAAAA", "age": 21}

task

{
  "type" : "index",
  "spec" : {
    "dataSchema" : {
      "dataSource" : "stringlaster",
      "parser" : {
        "type" : "string",
        "parseSpec" : {
          "format" : "json",
          "dimensionsSpec" : {
            "dimensions" : [
              "time",
              "personId",
              "name"
            ]
          },
          "timestampSpec" : {
            "format" : "auto",
            "column" : "time"
          }
        }
      },
      "metricsSpec" : [
        { "type" : "longSum", "name" : "age", "fieldName" : "age" }
      ],
      "granularitySpec" : {
        "type" : "uniform",
        "segmentGranularity" : "MONTH",
        "queryGranularity" : "none",
        "intervals" : ["2015-09-01/2015-10-01"],
        "rollup" : false
      }
    },
    "ioConfig" : {
      "type" : "index",
      "firehose" : {
        "type" : "local",
        "baseDir" : "quickstart/",
        "filter" : "stringlast_data.json"
      },
      "appendToExisting" : false
    },
    "tuningConfig" : {
      "type" : "index",
      "targetPartitionSize" : null,
      "maxRowsInMemory" : 25000,
      "forceGuaranteedRollup" : true,
      "numShards": 2
    }
  }
}

query, ordering by string last (wrong results):

{
  "queryType": "groupBy",
  "dataSource": { "type": "table", "name": "stringlaster" },
  "intervals": { "type": "intervals", "intervals": [ "2015-09-01/2015-10-01" ] },
  "granularity": { "type": "all" },
  "dimensions": [ "personId" ],
  "aggregations": [
    { "type": "stringLast", "name": "name", "fieldName": "name" },
    { "type": "longLast",   "name": "age", "fieldName": "age" }
  ],
  "limitSpec": {
    "type": "default", "limit": 1000,
    "columns" : [{ "dimension":"name","direction":"ascending","dimensionOrder":"alphanumeric"}]
  },
  "context": {}
}

wrong results for the above query:

[
  {
    "version": "v1",
    "timestamp": "2015-09-01T00:00:00.000Z",
    "event": {
      "name": "BBBBB",
      "personId": "1111",
      "age": 31
    }
  },
  {
    "version": "v1",
    "timestamp": "2015-09-01T00:00:00.000Z",
    "event": {
      "name": "AAAAA",
      "personId": "2222",
      "age": 21
    }
  }
]

query ordering by long last (correct results)

{
  "queryType": "groupBy",
  "dataSource": { "type": "table", "name": "stringlaster" },
  "intervals": { "type": "intervals", "intervals": [ "2015-09-01/2015-10-01" ] },
  "granularity": { "type": "all" },
  "dimensions": [ "personId" ],
  "aggregations": [
    { "type": "stringLast", "name": "name", "fieldName": "name" },
    { "type": "longLast",   "name": "age", "fieldName": "age" }
  ],
  "limitSpec": {
    "type": "default", "limit": 1000,
    "columns" : [{ "dimension":"age","direction":"ascending","dimensionOrder":"alphanumeric"}]
  },
  "context": {}
}

right results for above query:

[
  {
    "version": "v1",
    "timestamp": "2015-09-01T00:00:00.000Z",
    "event": {
      "name": "AAAAA",
      "personId": "2222",
      "age": 21
    }
  },
  {
    "version": "v1",
    "timestamp": "2015-09-01T00:00:00.000Z",
    "event": {
      "name": "BBBBB",
      "personId": "1111",
      "age": 31
    }
  }
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant