Skip to content

Commit 0493629

Browse files
committed
Add a yaml test that replicates issue 4201
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
1 parent 0660994 commit 0493629

3 files changed

Lines changed: 110 additions & 0 deletions

File tree

integ-test/src/test/resources/expectedOutput/calcite/agg_composite_date_range_push.yaml

Whitespace-only changes.

integ-test/src/test/resources/expectedOutput/calcite_no_pushdown/agg_composite_date_range_push.yaml

Whitespace-only changes.
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
setup:
2+
- do:
3+
query.settings:
4+
body:
5+
transient:
6+
plugins.calcite.enabled : true
7+
8+
- do:
9+
indices.create:
10+
index: test
11+
body:
12+
mappings:
13+
properties:
14+
"@timestamp":
15+
type: date
16+
timestamp:
17+
type: date
18+
size:
19+
type: long
20+
tmin:
21+
type: double
22+
metrics:
23+
type: object
24+
properties:
25+
size:
26+
type: long
27+
tmin:
28+
type: double
29+
30+
- do:
31+
bulk:
32+
index: test
33+
refresh: true
34+
body:
35+
- '{"index": {}}'
36+
- '{ "@timestamp": "2025-01-01T00:00:00Z", "timestamp": "2025-01-01T00:00:00Z", "size": -20, "tmin": 1.0, "metrics": { "size": -20, "tmin": 1.0 } }'
37+
- '{"index": {}}'
38+
- '{ "@timestamp": "2025-01-01T01:00:00Z", "timestamp": "2025-01-01T01:00:00Z", "size": 5, "tmin": 2.5, "metrics": { "size": 5, "tmin": 2.5 } }'
39+
- '{"index": {}}'
40+
- '{ "@timestamp": "2025-01-01T02:00:00Z", "timestamp": "2025-01-01T02:00:00Z", "size": 50, "tmin": 3.2, "metrics": { "size": 50, "tmin": 3.2 } }'
41+
- '{"index": {}}'
42+
- '{ "@timestamp": "2025-01-01T03:00:00Z", "timestamp": "2025-01-01T03:00:00Z", "size": 500, "tmin": 1.8, "metrics": { "size": 500, "tmin": 1.8 } }'
43+
- '{"index": {}}'
44+
- '{ "@timestamp": "2025-01-01T04:00:00Z", "timestamp": "2025-01-01T04:00:00Z", "size": 1500, "tmin": 4.1, "metrics": { "size": 1500, "tmin": 4.1 } }'
45+
- '{"index": {}}'
46+
- '{ "@timestamp": "2025-01-01T05:00:00Z", "timestamp": "2025-01-01T05:30:00Z", "size": 3000, "tmin": 2.9, "metrics": { "size": 3000, "tmin": 2.9 } }'
47+
48+
---
49+
teardown:
50+
- do:
51+
query.settings:
52+
body:
53+
transient:
54+
plugins.calcite.enabled : false
55+
56+
---
57+
"Test aggregation by range bucket":
58+
- skip:
59+
features:
60+
- headers
61+
- allowed_warnings
62+
- do:
63+
headers:
64+
Content-Type: 'application/json'
65+
ppl:
66+
body:
67+
query: |
68+
source = test
69+
| eval range_bucket = case(
70+
`metrics.size` < -10, 'range_1',
71+
`metrics.size` >= -10 and `metrics.size` < 10, 'range_2',
72+
`metrics.size` >= 10 and `metrics.size` < 100, 'range_3',
73+
`metrics.size` >= 100 and `metrics.size` < 1000, 'range_4',
74+
`metrics.size` >= 1000 and `metrics.size` < 2000, 'range_5',
75+
`metrics.size` >= 2000, 'range_6'
76+
)
77+
| stats min(`metrics.tmin`) as tmin, avg(`metrics.size`) as tavg, max(`metrics.size`) as tmax
78+
by range_bucket
79+
80+
- match: { total: 6 }
81+
- match: { schema: [{"name": "tmin", "type": "double"}, {"name": "tavg", "type": "double"}, {"name": "tmax", "type": "bigint"}, {"name": "range_bucket", "type": "string"}] }
82+
- match: { datarows: [[1.0, -20.0, -20, "range_1"], [2.5, 5.0, 5, "range_2"], [3.2, 50.0, 50, "range_3"], [1.8, 500.0, 500, "range_4"], [4.1, 1500.0, 1500, "range_5"], [2.9, 3000.0, 3000, "range_6"]] }
83+
84+
---
85+
"Test aggregation by range bucket and time span":
86+
- skip:
87+
features:
88+
- headers
89+
- allowed_warnings
90+
- do:
91+
headers:
92+
Content-Type: 'application/json'
93+
ppl:
94+
body:
95+
query: |
96+
source = test
97+
| eval range_bucket = case(
98+
`metrics.size` < -10, 'range_1',
99+
`metrics.size` >= -10 and `metrics.size` < 10, 'range_2',
100+
`metrics.size` >= 10 and `metrics.size` < 100, 'range_3',
101+
`metrics.size` >= 100 and `metrics.size` < 1000, 'range_4',
102+
`metrics.size` >= 1000 and `metrics.size` < 2000, 'range_5',
103+
`metrics.size` >= 2000, 'range_6'
104+
)
105+
| stats min(`metrics.tmin`) as tmin, avg(`metrics.size`) as tavg, max(`metrics.size`) as tmax
106+
by range_bucket, span(`@timestamp`, 1h)
107+
108+
- match: { total: 6 }
109+
- match: { schema: [{"name": "tmin", "type": "double"}, {"name": "tavg", "type": "double"}, {"name": "tmax", "type": "bigint"}, {"name": "span(`@timestamp`,1h)", "type": "timestamp"}, {"name": "range_bucket", "type": "string"}] }
110+
- match: { datarows: [[1.0, -20.0, -20, "2025-01-01 00:00:00", "range_1"], [2.5, 5.0, 5, "2025-01-01 01:00:00", "range_2"], [3.2, 50.0, 50, "2025-01-01 02:00:00", "range_3"], [1.8, 500.0, 500, "2025-01-01 03:00:00", "range_4"], [4.1, 1500.0, 1500, "2025-01-01 04:00:00", "range_5"], [2.9, 3000.0, 3000, "2025-01-01 05:00:00", "range_6"]] }

0 commit comments

Comments
 (0)