@@ -323,7 +323,7 @@ var AggregationTestsWithDates = []AggregationTestCase{
323323 ("@timestamp", 'Europe/Warsaw'))*1000) / 10000) AS "aggr__timeseries__key_0"
324324 ORDER BY "aggr__timeseries__key_0" ASC` ,
325325 },
326- { // [1 ]
326+ { // [2 ]
327327 TestName : "extended_bounds post keys (timezone calculations most tricky to get right)" ,
328328 QueryRequestJson : `
329329 {
@@ -504,4 +504,134 @@ var AggregationTestsWithDates = []AggregationTestCase{
504504 ("@timestamp", 'Europe/Warsaw'))*1000) / 10000) AS "aggr__timeseries__key_0"
505505 ORDER BY "aggr__timeseries__key_0" ASC` ,
506506 },
507+ { // [3]
508+ TestName : "empty results, we still should add empty buckets, because of the extended_bounds and min_doc_count defaulting to 0" ,
509+ QueryRequestJson : `
510+ {
511+ "_source": {
512+ "excludes": []
513+ },
514+ "aggs": {
515+ "0": {
516+ "aggs": {
517+ "1": {
518+ "sum": {
519+ "field": "body_bytes_sent"
520+ }
521+ }
522+ },
523+ "date_histogram": {
524+ "calendar_interval": "1d",
525+ "extended_bounds": {
526+ "min": 1732327903466,
527+ "max": 1732713503466
528+ },
529+ "field": "@timestamp",
530+ "time_zone": "Europe/Warsaw"
531+ }
532+ }
533+ },
534+ "query": {
535+ "bool": {
536+ "filter": [
537+ {
538+ "range": {
539+ "@timestamp": {
540+ "format": "strict_date_optional_time",
541+ "gte": "2009-11-27T13:18:23.466Z",
542+ "lte": "2024-11-27T13:18:23.466Z"
543+ }
544+ }
545+ }
546+ ],
547+ "must": [],
548+ "must_not": [],
549+ "should": []
550+ }
551+ },
552+ "runtime_mappings": {},
553+ "script_fields": {},
554+ "size": 0,
555+ "stored_fields": [
556+ "*"
557+ ],
558+ "track_total_hits": true
559+ }` ,
560+ ExpectedResponse : `
561+ {
562+ "completion_time_in_millis": 1707486436398,
563+ "expiration_time_in_millis": 1707486496397,
564+ "is_partial": false,
565+ "is_running": false,
566+ "response": {
567+ "_shards": {
568+ "failed": 0,
569+ "skipped": 0,
570+ "successful": 1,
571+ "total": 1
572+ },
573+ "aggregations": {
574+ "0": {
575+ "buckets": [
576+ {
577+ "doc_count": 0,
578+ "key": 1732402800000,
579+ "key_as_string": "2024-11-23T23:00:00.000",
580+ "1": {
581+ "value": null
582+ }
583+ },
584+ {
585+ "doc_count": 0,
586+ "key": 1732489200000,
587+ "key_as_string": "2024-11-24T23:00:00.000",
588+ "1": {
589+ "value": null
590+ }
591+ },
592+ {
593+ "doc_count": 0,
594+ "key": 1732575600000,
595+ "key_as_string": "2024-11-25T23:00:00.000",
596+ "1": {
597+ "value": null
598+ }
599+ },
600+ {
601+ "doc_count": 0,
602+ "key": 1732662000000,
603+ "key_as_string": "2024-11-26T23:00:00.000",
604+ "1": {
605+ "value": null
606+ }
607+ }
608+ ]
609+ }
610+ },
611+ "hits": {
612+ "hits": [],
613+ "max_score": null,
614+ "total": {
615+ "relation": "eq",
616+ "value": 2200
617+ }
618+ },
619+ "timed_out": false,
620+ "took": 1
621+ },
622+ "start_time_in_millis": 1707486436397
623+ }` ,
624+ ExpectedPancakeResults : []model.QueryResultRow {},
625+ ExpectedPancakeSQL : `
626+ SELECT toInt64((toUnixTimestamp64Milli("@timestamp")+timeZoneOffset(toTimezone(
627+ "@timestamp", 'Europe/Warsaw'))*1000) / 86400000) AS "aggr__0__key_0",
628+ count(*) AS "aggr__0__count",
629+ sumOrNull("body_bytes_sent") AS "metric__0__1_col_0"
630+ FROM __quesma_table_name
631+ WHERE ("@timestamp">=fromUnixTimestamp64Milli(1259327903466) AND "@timestamp"<=
632+ fromUnixTimestamp64Milli(1732713503466))
633+ GROUP BY toInt64((toUnixTimestamp64Milli("@timestamp")+timeZoneOffset(toTimezone
634+ ("@timestamp", 'Europe/Warsaw'))*1000) / 86400000) AS "aggr__0__key_0"
635+ ORDER BY "aggr__0__key_0" ASC` ,
636+ },
507637}
0 commit comments