Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
trzysiek committed May 7, 2024
1 parent 7d86155 commit 65c84e6
Showing 1 changed file with 140 additions and 0 deletions.
140 changes: 140 additions & 0 deletions quesma/testdata/opensearch-visualize/aggregation_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,4 +620,144 @@ var AggregationTests = []testdata.AggregationTestCase{
`WHERE "epoch_time">='2024-04-18T04:40:12.252Z' AND "epoch_time"<='2024-05-03T04:40:12.252Z' `,
},
},
{ // [4]
TestName: "Min/max with simple script. Reproduce: Visualize -> Line -> Metrics: Count, Buckets: X-Asis Histogram",
QueryRequestJson: `
{
"_source": {
"excludes": []
},
"aggs": {
"maxAgg": {
"max": {
"script": {
"lang": "painless",
"source": "doc['timestamp'].value.getHour()"
}
}
},
"minAgg": {
"min": {
"script": {
"lang": "painless",
"source": "doc['timestamp'].value.getHour()"
}
}
}
},
"docvalue_fields": [
{
"field": "@timestamp",
"format": "date_time"
},
{
"field": "timestamp",
"format": "date_time"
},
{
"field": "utc_time",
"format": "date_time"
}
],
"query": {
"bool": {
"filter": [],
"must": [
{
"match_all": {}
}
],
"must_not": [],
"should": []
}
},
"script_fields": {
"hour_of_day": {
"script": {
"lang": "painless",
"source": "doc['timestamp'].value.getHour()"
}
}
},
"size": 0,
"stored_fields": [
"*"
]
}`,
ExpectedResponse: ``,
ExpectedResults: [][]model.QueryResultRow{},
ExpectedSQLs: []string{},
},
{ // [5]
TestName: "Histogram with simple script. Reproduce: Visualize -> Line -> Metrics: Count, Buckets: X-Asis Histogram",
QueryRequestJson: `
{
"_source": {
"excludes": []
},
"aggs": {
"2": {
"histogram": {
"interval": 1,
"min_doc_count": 1,
"script": {
"lang": "painless",
"source": "doc['timestamp'].value.getHour()"
}
}
}
},
"docvalue_fields": [
{
"field": "@timestamp",
"format": "date_time"
},
{
"field": "timestamp",
"format": "date_time"
},
{
"field": "utc_time",
"format": "date_time"
}
],
"query": {
"bool": {
"filter": [
{
"range": {
"timestamp": {
"format": "strict_date_optional_time",
"gte": "2024-05-07T20:32:10.918Z",
"lte": "2024-05-07T20:47:10.918Z"
}
}
}
],
"must": [
{
"match_all": {}
}
],
"must_not": [],
"should": []
}
},
"script_fields": {
"hour_of_day": {
"script": {
"lang": "painless",
"source": "doc['timestamp'].value.getHour()"
}
}
},
"size": 0,
"stored_fields": [
"*"
]
}`,
ExpectedResponse: ``,
ExpectedResults: [][]model.QueryResultRow{},
ExpectedSQLs: []string{},
},
}

0 comments on commit 65c84e6

Please sign in to comment.