|
| 1 | +setup: |
| 2 | + - do: |
| 3 | + indices.create: |
| 4 | + index: timechart-eval-bug |
| 5 | + body: |
| 6 | + mappings: |
| 7 | + properties: |
| 8 | + "@timestamp": |
| 9 | + type: date |
| 10 | + "user": |
| 11 | + type: keyword |
| 12 | + - do: |
| 13 | + bulk: |
| 14 | + index: timechart-eval-bug |
| 15 | + refresh: true |
| 16 | + body: |
| 17 | + - '{"index":{}}' |
| 18 | + - '{"@timestamp":"2024-05-01T00:15:00Z","user":"alice"}' |
| 19 | + - '{"index":{}}' |
| 20 | + - '{"@timestamp":"2024-05-01T00:30:00Z","user":"bob"}' |
| 21 | + - '{"index":{}}' |
| 22 | + - '{"@timestamp":"2024-05-02T00:45:00Z","user":"alice"}' |
| 23 | + - '{"index":{}}' |
| 24 | + - '{"@timestamp":"2024-05-03T00:20:00Z","user":"bob"}' |
| 25 | + |
| 26 | +--- |
| 27 | +"timechart with eval on @timestamp field": |
| 28 | + - skip: |
| 29 | + features: |
| 30 | + - headers |
| 31 | + - do: |
| 32 | + headers: |
| 33 | + Content-Type: 'application/json' |
| 34 | + ppl: |
| 35 | + body: |
| 36 | + query: source=timechart-eval-bug | where HOUR(@timestamp) = 0 | timechart span=1d COUNT() by user | eval copyTimestamp = @timestamp |
| 37 | + |
| 38 | + - match: { total: 4 } |
| 39 | + - match: { "schema": [ { "name": "@timestamp", "type": "timestamp" }, { "name": "user", "type": "string" }, { "name": "COUNT()", "type": "bigint" }, { "name": "copyTimestamp", "type": "timestamp" }] } |
| 40 | + - match: {"datarows": [["2024-05-01 00:00:00", "alice", 1, "2024-05-01 00:00:00"], ["2024-05-01 00:00:00", "bob", 1, "2024-05-01 00:00:00"], ["2024-05-02 00:00:00", "alice", 1, "2024-05-02 00:00:00"], ["2024-05-03 00:00:00", "bob", 1, "2024-05-03 00:00:00"]]} |
| 41 | + |
| 42 | +--- |
| 43 | +"timechart with eval on by field": |
| 44 | + - skip: |
| 45 | + features: |
| 46 | + - headers |
| 47 | + - do: |
| 48 | + headers: |
| 49 | + Content-Type: 'application/json' |
| 50 | + ppl: |
| 51 | + body: |
| 52 | + query: source=timechart-eval-bug | where HOUR(@timestamp) = 0 | timechart span=1d COUNT() by user | eval copyUser = user |
| 53 | + |
| 54 | + - match: { total: 4 } |
| 55 | + - match: { "schema": [ { "name": "@timestamp", "type": "timestamp" }, { "name": "user", "type": "string" }, { "name": "COUNT()", "type": "bigint" }, { "name": "copyUser", "type": "string" }] } |
| 56 | + - match: {"datarows": [["2024-05-01 00:00:00", "alice", 1, "alice"], ["2024-05-01 00:00:00", "bob", 1, "bob"], ["2024-05-02 00:00:00", "alice", 1, "alice"], ["2024-05-03 00:00:00", "bob", 1, "bob"]]} |
| 57 | + |
| 58 | +--- |
| 59 | +"timechart with eval on aggregated field": |
| 60 | + - skip: |
| 61 | + features: |
| 62 | + - headers |
| 63 | + - do: |
| 64 | + headers: |
| 65 | + Content-Type: 'application/json' |
| 66 | + ppl: |
| 67 | + body: |
| 68 | + query: source=timechart-eval-bug | where HOUR(@timestamp) = 0 | timechart span=1d COUNT() by user | eval doubleCount = `COUNT()` * 2 |
| 69 | + |
| 70 | + - match: { total: 4 } |
| 71 | + - match: { "schema": [ { "name": "@timestamp", "type": "timestamp" }, { "name": "user", "type": "string" }, { "name": "COUNT()", "type": "bigint" }, { "name": "doubleCount", "type": "bigint" }] } |
| 72 | + - match: {"datarows": [["2024-05-01 00:00:00", "alice", 1, 2], ["2024-05-01 00:00:00", "bob", 1, 2], ["2024-05-02 00:00:00", "alice", 1, 2], ["2024-05-03 00:00:00", "bob", 1, 2]]} |
| 73 | + |
| 74 | +--- |
| 75 | +"timechart with DATE_FORMAT on @timestamp": |
| 76 | + - skip: |
| 77 | + features: |
| 78 | + - headers |
| 79 | + - do: |
| 80 | + headers: |
| 81 | + Content-Type: 'application/json' |
| 82 | + ppl: |
| 83 | + body: |
| 84 | + query: source=timechart-eval-bug | where HOUR(@timestamp) = 0 | timechart span=1d COUNT() by user | eval formatted_date = DATE_FORMAT(@timestamp, 'yyyy-MM-dd') |
| 85 | + |
| 86 | + - match: { total: 4 } |
| 87 | + - match: { "schema": [ { "name": "@timestamp", "type": "timestamp" }, { "name": "user", "type": "string" }, { "name": "COUNT()", "type": "bigint" }, { "name": "formatted_date", "type": "string" }] } |
| 88 | + - match: {"datarows": [["2024-05-01 00:00:00", "alice", 1, "2024-05-01"], ["2024-05-01 00:00:00", "bob", 1, "2024-05-01"], ["2024-05-02 00:00:00", "alice", 1, "2024-05-02"], ["2024-05-03 00:00:00", "bob", 1, "2024-05-03"]]} |
0 commit comments