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

[BUG] Aggregate on date function does not work as expected #645

Closed
Tracked by #817
penghuo opened this issue Jun 20, 2022 · 3 comments · Fixed by #1061
Closed
Tracked by #817

[BUG] Aggregate on date function does not work as expected #645

penghuo opened this issue Jun 20, 2022 · 3 comments · Fixed by #1061
Assignees
Labels
bug Something isn't working v2.6.0

Comments

@penghuo
Copy link
Collaborator

penghuo commented Jun 20, 2022

What is the bug?

PUT {{baseUrl}}/test_00001/
Content-Type: application/json

{
  "settings": {
    "index": {
      "number_of_shards": 1,
      "number_of_replicas": 0
    }
  },
  "mappings": {
    "properties": {
      "date": {
        "type": "keyword"
      },
      "status": {
        "type": "integer"
      }   
    }
  }
}

curl -XPOST "http://localhost:9200/_bulk?refresh=true" -H 'Content-Type: application/json' -d'
{ "index" : { "_index" : "test_00001", "_id" : "1" } }
{ "date" : "2022-01-01", "status" : 1}
{ "index" : { "_index" : "test_00001", "_id" : "2" } }
{ "date" : "2022-02-01", "status" : 2}
{ "index" : { "_index" : "test_00001", "_id" : "3" } }
{ "date" : "2022-03-01", "status" : 3}
{ "index" : { "_index" : "test_00001", "_id" : "4" } }
{ "date" : "2022-04-01", "status" : 2}
'

POST {{baseUrl}}/_plugins/_sql
Content-Type: application/json

{
  "query": "SELECT min(date(date)) FROM test_00001 GROUP BY status"
}

{
  "error": {
    "type": "SearchPhaseExecutionException",
    "reason": "Error occurred in OpenSearch engine: all shards failed",
    "details": "Shard[0]: AggregationExecutionException[Unsupported script value [2022-01-01], expected a number, date, or boolean]\n\nFor more details, please send request for Json format to see the raw response from OpenSearch engine."
  },
  "status": 503
}
@penghuo penghuo added bug Something isn't working untriaged and removed untriaged labels Jun 20, 2022
@penghuo
Copy link
Collaborator Author

penghuo commented Jun 20, 2022

ScriptAggregate works on number/date/boolean data type. ExprDateValue return string which is not expected.

@dai-chen
Copy link
Collaborator

@Yury-Fridlyand just to confirm can we close this now?

@Yury-Fridlyand
Copy link
Collaborator

No, the fix is in #1061, it is not merged yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v2.6.0
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants