prometheus/promql/parser/generated_parser.y.go

2452 lines
63 KiB
Go
Raw Permalink Normal View History

// Code generated by goyacc -l -o promql/parser/generated_parser.y.go promql/parser/generated_parser.y. DO NOT EDIT.
package parser
import __yyfmt__ "fmt"
import (
"math"
"strconv"
"time"
"github.com/prometheus/prometheus/model/histogram"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/model/value"
"github.com/prometheus/prometheus/promql/parser/posrange"
"github.com/prometheus/common/model"
)
type yySymType struct {
yys int
node Node
item Item
matchers []*labels.Matcher
matcher *labels.Matcher
label labels.Label
labels labels.Labels
lblList []labels.Label
strings []string
series []SequenceValue
histogram *histogram.FloatHistogram
descriptors map[string]interface{}
bucket_set []float64
int int64
uint uint64
float float64
}
const EQL = 57346
const BLANK = 57347
const COLON = 57348
const COMMA = 57349
const COMMENT = 57350
const DURATION = 57351
const EOF = 57352
const ERROR = 57353
const IDENTIFIER = 57354
const LEFT_BRACE = 57355
const LEFT_BRACKET = 57356
const LEFT_PAREN = 57357
const OPEN_HIST = 57358
const CLOSE_HIST = 57359
const METRIC_IDENTIFIER = 57360
const NUMBER = 57361
const RIGHT_BRACE = 57362
const RIGHT_BRACKET = 57363
const RIGHT_PAREN = 57364
const SEMICOLON = 57365
const SPACE = 57366
const STRING = 57367
const TIMES = 57368
const histogramDescStart = 57369
const SUM_DESC = 57370
const COUNT_DESC = 57371
const SCHEMA_DESC = 57372
const OFFSET_DESC = 57373
const NEGATIVE_OFFSET_DESC = 57374
const BUCKETS_DESC = 57375
const NEGATIVE_BUCKETS_DESC = 57376
const ZERO_BUCKET_DESC = 57377
const ZERO_BUCKET_WIDTH_DESC = 57378
const CUSTOM_VALUES_DESC = 57379
const COUNTER_RESET_HINT_DESC = 57380
const histogramDescEnd = 57381
const operatorsStart = 57382
const ADD = 57383
const DIV = 57384
const EQLC = 57385
const EQL_REGEX = 57386
const GTE = 57387
const GTR = 57388
const TRIM_UPPER = 57389
const TRIM_LOWER = 57390
const LAND = 57391
const LOR = 57392
const LSS = 57393
const LTE = 57394
const LUNLESS = 57395
const MOD = 57396
const MUL = 57397
const NEQ = 57398
const NEQ_REGEX = 57399
const POW = 57400
const SUB = 57401
const AT = 57402
const ATAN2 = 57403
const operatorsEnd = 57404
const aggregatorsStart = 57405
const AVG = 57406
const BOTTOMK = 57407
const COUNT = 57408
const COUNT_VALUES = 57409
const GROUP = 57410
const MAX = 57411
const MIN = 57412
const QUANTILE = 57413
const STDDEV = 57414
const STDVAR = 57415
const SUM = 57416
const TOPK = 57417
const LIMITK = 57418
const LIMIT_RATIO = 57419
const aggregatorsEnd = 57420
const keywordsStart = 57421
const BOOL = 57422
const BY = 57423
const GROUP_LEFT = 57424
const GROUP_RIGHT = 57425
const FILL = 57426
const FILL_LEFT = 57427
const FILL_RIGHT = 57428
const IGNORING = 57429
const OFFSET = 57430
const SMOOTHED = 57431
const ANCHORED = 57432
const ON = 57433
const WITHOUT = 57434
const keywordsEnd = 57435
const preprocessorStart = 57436
const START = 57437
const END = 57438
const STEP = 57439
const RANGE = 57440
const preprocessorEnd = 57441
const counterResetHintsStart = 57442
const UNKNOWN_COUNTER_RESET = 57443
const COUNTER_RESET = 57444
const NOT_COUNTER_RESET = 57445
const GAUGE_TYPE = 57446
const counterResetHintsEnd = 57447
const startSymbolsStart = 57448
const START_METRIC = 57449
const START_SERIES_DESCRIPTION = 57450
const START_EXPRESSION = 57451
const START_METRIC_SELECTOR = 57452
const startSymbolsEnd = 57453
var yyToknames = [...]string{
"$end",
"error",
"$unk",
"EQL",
"BLANK",
"COLON",
"COMMA",
"COMMENT",
"DURATION",
"EOF",
"ERROR",
"IDENTIFIER",
"LEFT_BRACE",
"LEFT_BRACKET",
"LEFT_PAREN",
"OPEN_HIST",
"CLOSE_HIST",
"METRIC_IDENTIFIER",
"NUMBER",
"RIGHT_BRACE",
"RIGHT_BRACKET",
"RIGHT_PAREN",
"SEMICOLON",
"SPACE",
"STRING",
"TIMES",
"histogramDescStart",
"SUM_DESC",
"COUNT_DESC",
"SCHEMA_DESC",
"OFFSET_DESC",
"NEGATIVE_OFFSET_DESC",
"BUCKETS_DESC",
"NEGATIVE_BUCKETS_DESC",
"ZERO_BUCKET_DESC",
"ZERO_BUCKET_WIDTH_DESC",
"CUSTOM_VALUES_DESC",
"COUNTER_RESET_HINT_DESC",
"histogramDescEnd",
"operatorsStart",
"ADD",
"DIV",
"EQLC",
"EQL_REGEX",
"GTE",
"GTR",
"TRIM_UPPER",
"TRIM_LOWER",
"LAND",
"LOR",
"LSS",
"LTE",
"LUNLESS",
"MOD",
"MUL",
"NEQ",
"NEQ_REGEX",
"POW",
"SUB",
"AT",
"ATAN2",
"operatorsEnd",
"aggregatorsStart",
"AVG",
"BOTTOMK",
"COUNT",
"COUNT_VALUES",
"GROUP",
"MAX",
"MIN",
"QUANTILE",
"STDDEV",
"STDVAR",
"SUM",
"TOPK",
feat: add limitk() and limit_ratio() operators (#12503) * rebase 2024-07-01, picks previous renaming to `limitk()` and `limit_ratio()` Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * gofumpt -d -extra Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * more lint fixes Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * more lint fixes+ Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * put limitk() and limit_ratio() behind --enable-feature=promql-experimental-functions Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * EnableExperimentalFunctions for TestConcurrentRangeQueries() also Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * use testutil.RequireEqual to fix tests, WIP equivalent thingie for require.Contains Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * lint fix Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * moar linting Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * rebase 2024-06-19 Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * re-add limit(2, metric) testing for N=2 common series subset Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * move `ratio = param` to default switch case, for better readability Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * gofumpt -d -extra util/testutil/cmp.go Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * early break when reaching k elems in limitk(), should have always been so (!) Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * small typo fix Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * no-change small break-loop rearrange for readability Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * remove IsNan(ratio) condition in switch-case, already handled as input validation Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * no-change adding some comments Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * no-change simplify fullMatrix() helper functions used for tests Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * add `limitk(-1, metric)` testcase, which is handled as any k < 1 case Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * engine_test.go: no-change create `requireCommonSeries() helper func (moving code into it) for readability Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * rebase 2024-06-21 Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * engine_test.go: HAPPY NOW about its code -> reorg, create and use simpleRangeQuery() function, less lines and more readable ftW \o/ Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * move limitk(), limit_ratio() testing to promql/promqltest/testdata/limit.test Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * remove stale leftover after moving tests from engine_test.go to testdata/ Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * fix flaky `limit_ratio(0.5, ...)` test case Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * Update promql/engine.go Co-authored-by: Julius Volz <julius.volz@gmail.com> Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * Update promql/engine.go Co-authored-by: Julius Volz <julius.volz@gmail.com> Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * Update promql/engine.go Co-authored-by: Julius Volz <julius.volz@gmail.com> Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * fix AddRatioSample() implementation to use a single conditional (instead of switch/case + fallback return) Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * docs/querying/operators.md: document r < 0 Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * add negative limit_ratio() example to docs/querying/examples.md Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * move more extensive docu examples to docs/querying/operators.md Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * typo Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * small docu fix for poor-mans-normality-check, add it to limit.test ;) Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * limit.test: expand "Poor man's normality check" to whole eval range Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * restore mistakenly removed existing small comment Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * expand poors-man-normality-check case(s) Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * Revert "expand poors-man-normality-check case(s)" This reverts commit f69e1603b2ebe69c0a100197cfbcf6f81644b564, indeed too flaky 0:) Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * remove humor from docs/querying/operators.md Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * fix signoff Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * add web/ui missing changes Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * expand limit_ratio test cases, cross-fingering they'll not be flaky Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * remove flaky test Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * add missing warnings.Merge(ws) in instant-query return shortcut Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * add missing LimitK||LimitRatio case to codemirror-promql/src/parser/parser.ts Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * fix ui-lint Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * actually fix returned warnings :] Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> --------- Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> Co-authored-by: Julius Volz <julius.volz@gmail.com>
2024-07-03 16:18:57 -04:00
"LIMITK",
"LIMIT_RATIO",
"aggregatorsEnd",
"keywordsStart",
"BOOL",
"BY",
"GROUP_LEFT",
"GROUP_RIGHT",
"FILL",
"FILL_LEFT",
"FILL_RIGHT",
"IGNORING",
"OFFSET",
Add anchored and smoothed to vector selectors. (#16457) * Add anchored and smoothed to vector selectors. This adds "anchored" and "smoothed" keywords that can be used following a matrix selector. "Anchored" selects the last point before the range (or the first one after the range) and adds it at the boundary of the matrix selector. "Smoothed" applies linear interpolation at the edges using the points around the edges. In the absence of a point before or after the edge, the first or the last point is added to the edge, without interpolation. *Exemple usage* * `increase(caddy_http_requests_total[5m] anchored)` (equivalent of *caddy_http_requests_total - caddy_http_requests_total offset 5m* but takes counter reset into consideration) * `rate(caddy_http_requests_total[step()] smoothed)` Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Update docs/feature_flags.md Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> * Smoothed/Anchored rate: Add more tests Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Anchored/Smoothed modifier: error out with histograms Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> --------- Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
2025-09-25 05:34:59 -04:00
"SMOOTHED",
"ANCHORED",
"ON",
"WITHOUT",
"keywordsEnd",
"preprocessorStart",
"START",
"END",
"STEP",
"RANGE",
"preprocessorEnd",
"counterResetHintsStart",
"UNKNOWN_COUNTER_RESET",
"COUNTER_RESET",
"NOT_COUNTER_RESET",
"GAUGE_TYPE",
"counterResetHintsEnd",
"startSymbolsStart",
"START_METRIC",
"START_SERIES_DESCRIPTION",
"START_EXPRESSION",
"START_METRIC_SELECTOR",
"startSymbolsEnd",
}
var yyStatenames = [...]string{}
const yyEofCode = 1
const yyErrCode = 2
const yyInitialStackSize = 16
var yyExca = [...]int16{
-1, 1,
1, -1,
-2, 0,
-1, 44,
1, 163,
10, 163,
24, 163,
-2, 0,
-1, 75,
2, 206,
15, 206,
81, 206,
92, 206,
-2, 117,
-1, 76,
2, 207,
15, 207,
81, 207,
92, 207,
-2, 118,
-1, 77,
2, 208,
15, 208,
81, 208,
92, 208,
-2, 120,
-1, 78,
2, 209,
15, 209,
81, 209,
92, 209,
-2, 121,
-1, 79,
2, 210,
15, 210,
81, 210,
92, 210,
-2, 125,
-1, 80,
2, 211,
15, 211,
81, 211,
92, 211,
-2, 130,
-1, 81,
2, 212,
15, 212,
81, 212,
92, 212,
-2, 132,
-1, 82,
2, 213,
15, 213,
81, 213,
92, 213,
-2, 134,
-1, 83,
2, 214,
15, 214,
81, 214,
92, 214,
-2, 135,
-1, 84,
2, 215,
15, 215,
81, 215,
92, 215,
-2, 136,
-1, 85,
2, 216,
15, 216,
81, 216,
92, 216,
-2, 137,
-1, 86,
2, 217,
15, 217,
81, 217,
92, 217,
-2, 138,
-1, 87,
2, 218,
15, 218,
81, 218,
92, 218,
-2, 142,
-1, 88,
2, 219,
15, 219,
81, 219,
92, 219,
-2, 143,
-1, 142,
41, 290,
42, 290,
54, 290,
55, 290,
59, 290,
Add anchored and smoothed to vector selectors. (#16457) * Add anchored and smoothed to vector selectors. This adds "anchored" and "smoothed" keywords that can be used following a matrix selector. "Anchored" selects the last point before the range (or the first one after the range) and adds it at the boundary of the matrix selector. "Smoothed" applies linear interpolation at the edges using the points around the edges. In the absence of a point before or after the edge, the first or the last point is added to the edge, without interpolation. *Exemple usage* * `increase(caddy_http_requests_total[5m] anchored)` (equivalent of *caddy_http_requests_total - caddy_http_requests_total offset 5m* but takes counter reset into consideration) * `rate(caddy_http_requests_total[step()] smoothed)` Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Update docs/feature_flags.md Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> * Smoothed/Anchored rate: Add more tests Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Anchored/Smoothed modifier: error out with histograms Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> --------- Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
2025-09-25 05:34:59 -04:00
-2, 22,
-1, 262,
9, 275,
12, 275,
13, 275,
18, 275,
19, 275,
25, 275,
41, 275,
49, 275,
50, 275,
53, 275,
59, 275,
64, 275,
65, 275,
66, 275,
67, 275,
68, 275,
69, 275,
70, 275,
71, 275,
72, 275,
73, 275,
74, 275,
75, 275,
76, 275,
77, 275,
81, 275,
84, 275,
85, 275,
86, 275,
88, 275,
89, 275,
90, 275,
92, 275,
95, 275,
96, 275,
97, 275,
98, 275,
-2, 0,
-1, 263,
9, 275,
12, 275,
13, 275,
18, 275,
19, 275,
25, 275,
41, 275,
49, 275,
50, 275,
53, 275,
59, 275,
64, 275,
65, 275,
66, 275,
67, 275,
68, 275,
69, 275,
70, 275,
71, 275,
72, 275,
73, 275,
74, 275,
75, 275,
76, 275,
77, 275,
81, 275,
84, 275,
85, 275,
86, 275,
88, 275,
89, 275,
90, 275,
92, 275,
95, 275,
96, 275,
97, 275,
98, 275,
-2, 0,
}
const yyPrivate = 57344
const yyLast = 1241
var yyAct = [...]int16{
61, 369, 194, 435, 357, 442, 437, 299, 251, 205,
98, 51, 149, 197, 73, 96, 235, 260, 375, 376,
134, 261, 68, 135, 133, 132, 449, 450, 451, 452,
418, 419, 198, 137, 136, 257, 258, 259, 262, 263,
165, 70, 126, 129, 131, 125, 432, 431, 397, 125,
348, 159, 236, 227, 237, 130, 128, 395, 395, 131,
127, 404, 464, 453, 421, 202, 457, 140, 420, 142,
6, 385, 103, 105, 106, 201, 107, 108, 109, 110,
111, 112, 113, 114, 115, 116, 117, 118, 138, 119,
120, 124, 104, 119, 239, 124, 46, 203, 436, 135,
126, 129, 151, 383, 382, 230, 238, 240, 229, 255,
136, 143, 370, 130, 128, 204, 380, 131, 127, 121,
123, 122, 190, 121, 123, 122, 207, 212, 213, 214,
215, 216, 217, 185, 379, 65, 189, 208, 208, 208,
208, 208, 208, 208, 186, 64, 378, 231, 209, 209,
209, 209, 209, 209, 209, 220, 223, 218, 208, 219,
347, 345, 145, 139, 65, 141, 351, 89, 241, 209,
243, 144, 426, 253, 64, 2, 3, 4, 5, 125,
349, 352, 291, 346, 344, 90, 249, 286, 247, 237,
202, 425, 254, 252, 290, 203, 443, 255, 281, 353,
201, 284, 289, 288, 287, 208, 103, 105, 137, 209,
286, 246, 245, 204, 160, 129, 209, 292, 293, 116,
117, 208, 203, 119, 120, 124, 104, 130, 128, 239,
146, 131, 209, 152, 226, 244, 222, 202, 91, 42,
204, 238, 240, 150, 151, 196, 343, 201, 7, 221,
415, 342, 202, 121, 123, 122, 100, 256, 414, 413,
371, 372, 201, 264, 265, 266, 267, 268, 269, 270,
271, 272, 273, 274, 275, 276, 277, 278, 279, 280,
373, 374, 377, 350, 203, 340, 381, 412, 99, 391,
384, 469, 158, 10, 390, 43, 207, 208, 97, 411,
339, 208, 204, 93, 202, 386, 242, 208, 209, 389,
468, 100, 209, 467, 201, 410, 471, 409, 209, 166,
167, 168, 169, 170, 171, 172, 173, 174, 175, 176,
177, 178, 179, 180, 181, 182, 203, 408, 199, 200,
470, 407, 393, 406, 405, 59, 296, 466, 403, 102,
295, 92, 1, 208, 204, 394, 396, 183, 398, 126,
129, 399, 400, 402, 209, 294, 126, 129, 152, 234,
401, 8, 130, 128, 233, 44, 131, 127, 150, 130,
128, 422, 416, 131, 127, 74, 148, 232, 388, 58,
99, 100, 208, 417, 155, 65, 57, 56, 428, 154,
97, 193, 55, 209, 430, 64, 434, 387, 95, 438,
439, 440, 153, 100, 424, 164, 445, 444, 447, 446,
455, 456, 157, 441, 156, 458, 54, 89, 69, 454,
53, 9, 9, 52, 302, 50, 208, 392, 459, 460,
429, 162, 224, 461, 315, 90, 463, 209, 126, 129,
321, 49, 163, 48, 427, 192, 191, 301, 465, 126,
129, 130, 128, 161, 47, 131, 127, 60, 250, 208,
472, 462, 130, 128, 354, 101, 131, 127, 248, 297,
209, 317, 318, 210, 211, 319, 94, 448, 195, 300,
62, 147, 0, 332, 0, 0, 303, 305, 307, 308,
309, 320, 322, 325, 326, 327, 328, 329, 333, 334,
0, 0, 304, 306, 310, 311, 312, 313, 314, 316,
323, 338, 337, 324, 302, 0, 423, 330, 331, 335,
336, 0, 228, 0, 315, 0, 0, 0, 0, 0,
321, 0, 0, 0, 298, 126, 129, 301, 0, 0,
0, 126, 129, 0, 0, 0, 0, 0, 130, 128,
0, 0, 131, 127, 130, 128, 0, 0, 131, 127,
0, 317, 318, 0, 0, 319, 0, 0, 0, 0,
0, 341, 0, 332, 0, 0, 303, 305, 307, 308,
309, 320, 322, 325, 326, 327, 328, 329, 333, 334,
0, 0, 304, 306, 310, 311, 312, 313, 314, 316,
323, 338, 337, 324, 0, 126, 129, 330, 331, 335,
336, 65, 0, 0, 63, 91, 0, 66, 130, 128,
25, 64, 131, 127, 225, 0, 0, 67, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 89, 0, 0, 0, 0, 0, 0,
0, 21, 22, 0, 0, 23, 0, 0, 0, 0,
0, 90, 0, 0, 0, 0, 75, 76, 77, 78,
79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
0, 0, 0, 13, 0, 0, 16, 17, 18, 0,
27, 41, 40, 0, 33, 0, 0, 34, 35, 71,
72, 65, 45, 0, 63, 91, 0, 66, 356, 0,
25, 64, 0, 0, 0, 355, 0, 67, 0, 359,
360, 358, 365, 367, 364, 366, 361, 362, 363, 368,
0, 0, 0, 89, 0, 0, 0, 0, 0, 0,
0, 21, 22, 0, 0, 23, 0, 0, 0, 0,
0, 90, 0, 0, 0, 0, 75, 76, 77, 78,
79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
0, 0, 0, 13, 0, 0, 16, 17, 18, 0,
27, 41, 40, 0, 33, 0, 0, 34, 35, 71,
72, 65, 0, 0, 63, 91, 0, 66, 433, 0,
25, 64, 0, 0, 0, 0, 0, 67, 0, 359,
360, 358, 365, 367, 364, 366, 361, 362, 363, 368,
0, 0, 0, 89, 0, 0, 206, 0, 0, 0,
0, 21, 22, 65, 0, 23, 0, 0, 0, 193,
0, 90, 0, 64, 0, 0, 75, 76, 77, 78,
79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
0, 0, 0, 13, 0, 89, 16, 17, 18, 0,
27, 41, 40, 0, 33, 20, 91, 34, 35, 71,
72, 25, 0, 90, 0, 0, 0, 0, 0, 0,
0, 0, 0, 192, 191, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 184, 0, 0,
0, 0, 21, 22, 65, 0, 23, 0, 0, 0,
193, 210, 211, 0, 64, 0, 0, 11, 12, 14,
15, 19, 24, 26, 28, 29, 30, 31, 32, 36,
37, 0, 0, 0, 13, 0, 89, 16, 17, 18,
0, 27, 41, 40, 0, 33, 20, 42, 34, 35,
38, 39, 25, 0, 90, 0, 0, 0, 0, 0,
0, 0, 0, 0, 192, 191, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 21, 22, 0, 0, 23, 0, 0,
0, 0, 187, 188, 0, 0, 0, 0, 11, 12,
14, 15, 19, 24, 26, 28, 29, 30, 31, 32,
36, 37, 125, 0, 0, 13, 0, 0, 16, 17,
18, 0, 27, 41, 40, 0, 33, 0, 0, 34,
35, 38, 39, 125, 0, 0, 0, 0, 0, 103,
105, 106, 0, 107, 108, 109, 110, 111, 112, 113,
114, 115, 116, 117, 118, 0, 119, 120, 124, 104,
103, 105, 106, 0, 107, 108, 109, 110, 111, 0,
113, 114, 115, 116, 117, 118, 0, 119, 120, 124,
104, 0, 0, 125, 0, 0, 121, 123, 122, 0,
65, 0, 0, 0, 0, 0, 193, 0, 125, 0,
64, 0, 0, 0, 0, 0, 0, 121, 123, 122,
103, 105, 106, 0, 107, 108, 109, 110, 0, 0,
113, 114, 89, 116, 117, 118, 105, 119, 120, 124,
104, 65, 0, 0, 0, 0, 0, 285, 116, 117,
90, 64, 119, 0, 124, 104, 0, 0, 0, 0,
192, 191, 0, 0, 0, 0, 0, 121, 123, 122,
0, 0, 0, 89, 0, 0, 0, 0, 0, 0,
0, 0, 121, 123, 122, 0, 0, 0, 210, 211,
0, 90, 0, 0, 0, 0, 0, 0, 0, 0,
0, 192, 191, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 282,
283,
}
var yyPact = [...]int16{
68, 238, 954, 954, 702, 873, -1000, -1000, -1000, 226,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, 388, -1000, 347, -1000, 1018, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, 1, 18, 193, -1000, -1000, 792, -1000, 792, 225,
-1000, 156, 147, 215, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, 366, -1000, -1000, 392, -1000, -1000, 420, 288, -1000,
-1000, 27, -1000, -40, -40, -40, -40, -40, -40, -40,
-40, -40, -40, -40, -40, -40, -40, -40, -40, -40,
-40, 915, -1000, -1000, 243, 834, 1101, 1101, 1101, 1101,
1101, 1101, 193, -58, -1000, 234, 234, 612, -1000, 31,
510, 35, -14, -1000, 86, 83, 1101, 367, -1000, -1000,
50, 185, -1000, -1000, 286, -1000, 210, -1000, 186, 181,
792, -1000, -49, -70, -44, -1000, 792, 792, 792, 792,
792, 792, 792, 792, 792, 792, 792, 792, 792, 792,
792, 792, 792, -1000, -1000, -1000, 1142, 189, 188, 187,
1, -1000, -1000, 1101, -1000, 167, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, 228, 228, 344, -1000, 1, -1000, 1101,
156, 147, 173, 173, -14, -14, -14, -14, -1000, -1000,
-1000, 522, -1000, -1000, 278, -1000, 1018, -1000, -1000, -1000,
-1000, 574, -1000, 231, -1000, 159, -1000, -1000, -1000, -1000,
-1000, 158, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 24,
154, 140, -1000, -1000, -1000, 701, 1104, 97, 97, 97,
234, 234, 234, 234, 35, 35, 165, 165, 165, 165,
165, 1089, 1039, 165, 165, 1089, 35, 35, 165, 35,
1104, -1000, 131, 119, 101, 1101, -14, 82, 81, 1101,
510, 49, -1000, -1000, -1000, 386, -1000, 287, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
Add anchored and smoothed to vector selectors. (#16457) * Add anchored and smoothed to vector selectors. This adds "anchored" and "smoothed" keywords that can be used following a matrix selector. "Anchored" selects the last point before the range (or the first one after the range) and adds it at the boundary of the matrix selector. "Smoothed" applies linear interpolation at the edges using the points around the edges. In the absence of a point before or after the edge, the first or the last point is added to the edge, without interpolation. *Exemple usage* * `increase(caddy_http_requests_total[5m] anchored)` (equivalent of *caddy_http_requests_total - caddy_http_requests_total offset 5m* but takes counter reset into consideration) * `rate(caddy_http_requests_total[step()] smoothed)` Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Update docs/feature_flags.md Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> * Smoothed/Anchored rate: Add more tests Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Anchored/Smoothed modifier: error out with histograms Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> --------- Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
2025-09-25 05:34:59 -04:00
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
792, 1101, -1000, -1000, -1000, -1000, -1000, -1000, 38, 38,
22, 38, 93, 93, 346, 44, -1000, -1000, 338, 337,
335, 331, 311, 309, 293, 281, 253, 252, 244, -1000,
126, -56, -54, -1000, -1000, -1000, -1000, -1000, 46, 42,
1101, 504, -1000, -1000, 407, -1000, 170, -1000, -1000, -1000,
432, -1000, 1018, 418, -1000, -1000, -1000, 38, -1000, 21,
20, 791, -1000, -1000, -1000, 39, 56, 56, 56, 228,
182, 182, 39, 182, 39, -75, 41, 155, 97, 97,
-1000, -1000, 59, -1000, 1101, -1000, -1000, -1000, -1000, -1000,
-1000, 38, 38, -1000, -1000, -1000, 38, -1000, -1000, -1000,
-1000, -1000, -1000, 56, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, 40, -1000, -1000, 1101, 325, -1000,
-1000, -1000, 289, -1000, -1000, 318, -1000, 295, -1000, -1000,
-1000, -1000, -1000,
}
var yyPgo = [...]int16{
0, 491, 12, 490, 7, 16, 489, 428, 22, 488,
10, 487, 14, 293, 371, 486, 15, 479, 19, 18,
478, 475, 8, 474, 4, 5, 471, 3, 6, 13,
468, 32, 2, 467, 464, 25, 214, 463, 453, 452,
96, 451, 442, 24, 441, 1, 41, 435, 11, 433,
430, 426, 415, 402, 397, 396, 389, 345, 0, 385,
9, 357, 352, 295,
}
var yyR1 = [...]int8{
0, 62, 62, 62, 62, 62, 62, 62, 40, 40,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 40, 40, 34, 34, 34, 34, 35, 35, 38,
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
38, 38, 38, 38, 38, 38, 38, 36, 39, 39,
52, 52, 44, 44, 44, 44, 37, 37, 37, 37,
37, 37, 18, 18, 18, 18, 17, 17, 17, 4,
4, 4, 45, 45, 41, 43, 43, 42, 42, 42,
53, 60, 49, 49, 50, 51, 33, 33, 33, 9,
9, 47, 55, 55, 55, 55, 55, 55, 56, 57,
57, 57, 46, 46, 46, 1, 1, 1, 2, 2,
2, 2, 2, 2, 2, 14, 14, 7, 7, 7,
Add anchored and smoothed to vector selectors. (#16457) * Add anchored and smoothed to vector selectors. This adds "anchored" and "smoothed" keywords that can be used following a matrix selector. "Anchored" selects the last point before the range (or the first one after the range) and adds it at the boundary of the matrix selector. "Smoothed" applies linear interpolation at the edges using the points around the edges. In the absence of a point before or after the edge, the first or the last point is added to the edge, without interpolation. *Exemple usage* * `increase(caddy_http_requests_total[5m] anchored)` (equivalent of *caddy_http_requests_total - caddy_http_requests_total offset 5m* but takes counter reset into consideration) * `rate(caddy_http_requests_total[step()] smoothed)` Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Update docs/feature_flags.md Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> * Smoothed/Anchored rate: Add more tests Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Anchored/Smoothed modifier: error out with histograms Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> --------- Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
2025-09-25 05:34:59 -04:00
7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 13, 13,
13, 13, 15, 15, 15, 16, 16, 16, 16, 16,
16, 16, 63, 21, 21, 21, 21, 20, 20, 20,
20, 20, 20, 20, 20, 20, 30, 30, 30, 22,
22, 22, 22, 23, 23, 23, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 25, 25, 26,
26, 26, 11, 11, 11, 11, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
Merge release 2.29 in main (#9196) * PromQL: Fix start and end keywords masking label and metric names This commit fixes an issue with the "at modifier" that introduced two new keywords: `start` and `end`. In grouping options and in metric names, these keywords took precedence over metric or label names, so that those metrics and labels could no longer be referenced. Signed-off-by: Clayton Peters <clayton.peters@man.com> * Add in additional tests for metrics and/or labels called start/end. Signed-off-by: Clayton Peters <clayton.peters@man.com> * *: Cut 2.29.0-rc.0 Signed-off-by: Frederic Branczyk <fbranczyk@gmail.com> * VERSION: bump to 2.29.0-rc.0 Signed-off-by: Frederic Branczyk <fbranczyk@gmail.com> * Remove experimental wording on size-based retention Followup of #9004 Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu> * Fix PR reference in changelog Signed-off-by: George Brighton <george@gebn.co.uk> * Describe EC2 availability zone IDs at most once per refresh (#9142) Signed-off-by: George Brighton <george@gebn.co.uk> * Describe EC2 availability zones at most once per SD load Closes #9142. Signed-off-by: George Brighton <george@gebn.co.uk> * Incorporate feedback Signed-off-by: George Brighton <george@gebn.co.uk> * Integrate feedback Signed-off-by: George Brighton <george@gebn.co.uk> * Add a compatibility note for macOS users. Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu> * *: Cut v2.29.0-rc.1 Signed-off-by: Frederic Branczyk <fbranczyk@gmail.com> * Fix `kuma_sd` targetgroup reporting (#9157) * Bundle all xDS targets into a single group Signed-off-by: austin ce <austin.cawley@gmail.com> * *: cut v2.29.0-rc.2 Signed-off-by: Frederic Branczyk <fbranczyk@gmail.com> * Rename links Signed-off-by: Levi Harrison <git@leviharrison.dev> * bump codemirror-promql to 0.17.0 Signed-off-by: Augustin Husson <husson.augustin@gmail.com> * *: cut v2.29.0 Signed-off-by: Frederic Branczyk <fbranczyk@gmail.com> * tsdb: align atomically accessed int64 (#9192) This prevents a panic in 32-bit archs: https://pkg.go.dev/sync/atomic#pkg-note-BUG Fixed #9190 Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu> * Release 2.29.1 (#9193) Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu> Co-authored-by: Clayton Peters <clayton.peters@man.com> Co-authored-by: Frederic Branczyk <fbranczyk@gmail.com> Co-authored-by: George Brighton <george@gebn.co.uk> Co-authored-by: Austin Cawley-Edwards <austin.cawley@gmail.com> Co-authored-by: Levi Harrison <git@leviharrison.dev> Co-authored-by: Augustin Husson <husson.augustin@gmail.com>
2021-08-12 12:38:06 -04:00
6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 8, 8, 5, 5,
5, 5, 48, 48, 29, 29, 31, 31, 32, 32,
28, 27, 27, 54, 10, 19, 19, 61, 61, 61,
61, 61, 61, 61, 61, 61, 61, 12, 12, 58,
58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
58, 59,
}
var yyR2 = [...]int8{
0, 2, 2, 2, 2, 2, 2, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Add anchored and smoothed to vector selectors. (#16457) * Add anchored and smoothed to vector selectors. This adds "anchored" and "smoothed" keywords that can be used following a matrix selector. "Anchored" selects the last point before the range (or the first one after the range) and adds it at the boundary of the matrix selector. "Smoothed" applies linear interpolation at the edges using the points around the edges. In the absence of a point before or after the edge, the first or the last point is added to the edge, without interpolation. *Exemple usage* * `increase(caddy_http_requests_total[5m] anchored)` (equivalent of *caddy_http_requests_total - caddy_http_requests_total offset 5m* but takes counter reset into consideration) * `rate(caddy_http_requests_total[step()] smoothed)` Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Update docs/feature_flags.md Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> * Smoothed/Anchored rate: Add more tests Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Anchored/Smoothed modifier: error out with histograms Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> --------- Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
2025-09-25 05:34:59 -04:00
1, 1, 1, 3, 3, 2, 2, 2, 2, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 1, 0, 1,
3, 3, 1, 1, 3, 3, 1, 3, 3, 3,
5, 5, 3, 4, 2, 1, 3, 1, 2, 1,
1, 1, 3, 4, 2, 3, 2, 3, 1, 2,
3, 1, 3, 3, 2, 2, 3, 5, 3, 1,
1, 4, 6, 5, 6, 5, 4, 3, 2, 2,
1, 1, 3, 4, 2, 3, 1, 2, 3, 3,
1, 3, 3, 2, 1, 2, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 3, 4,
2, 0, 3, 1, 2, 3, 3, 1, 3, 3,
2, 1, 2, 0, 3, 2, 1, 1, 3, 1,
3, 4, 1, 3, 5, 5, 1, 1, 1, 4,
3, 3, 2, 3, 1, 2, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 4, 3, 3,
1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
feat: add limitk() and limit_ratio() operators (#12503) * rebase 2024-07-01, picks previous renaming to `limitk()` and `limit_ratio()` Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * gofumpt -d -extra Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * more lint fixes Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * more lint fixes+ Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * put limitk() and limit_ratio() behind --enable-feature=promql-experimental-functions Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * EnableExperimentalFunctions for TestConcurrentRangeQueries() also Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * use testutil.RequireEqual to fix tests, WIP equivalent thingie for require.Contains Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * lint fix Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * moar linting Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * rebase 2024-06-19 Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * re-add limit(2, metric) testing for N=2 common series subset Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * move `ratio = param` to default switch case, for better readability Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * gofumpt -d -extra util/testutil/cmp.go Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * early break when reaching k elems in limitk(), should have always been so (!) Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * small typo fix Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * no-change small break-loop rearrange for readability Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * remove IsNan(ratio) condition in switch-case, already handled as input validation Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * no-change adding some comments Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * no-change simplify fullMatrix() helper functions used for tests Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * add `limitk(-1, metric)` testcase, which is handled as any k < 1 case Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * engine_test.go: no-change create `requireCommonSeries() helper func (moving code into it) for readability Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * rebase 2024-06-21 Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * engine_test.go: HAPPY NOW about its code -> reorg, create and use simpleRangeQuery() function, less lines and more readable ftW \o/ Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * move limitk(), limit_ratio() testing to promql/promqltest/testdata/limit.test Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * remove stale leftover after moving tests from engine_test.go to testdata/ Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * fix flaky `limit_ratio(0.5, ...)` test case Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * Update promql/engine.go Co-authored-by: Julius Volz <julius.volz@gmail.com> Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * Update promql/engine.go Co-authored-by: Julius Volz <julius.volz@gmail.com> Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * Update promql/engine.go Co-authored-by: Julius Volz <julius.volz@gmail.com> Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * fix AddRatioSample() implementation to use a single conditional (instead of switch/case + fallback return) Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * docs/querying/operators.md: document r < 0 Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * add negative limit_ratio() example to docs/querying/examples.md Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * move more extensive docu examples to docs/querying/operators.md Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * typo Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * small docu fix for poor-mans-normality-check, add it to limit.test ;) Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * limit.test: expand "Poor man's normality check" to whole eval range Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * restore mistakenly removed existing small comment Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * expand poors-man-normality-check case(s) Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * Revert "expand poors-man-normality-check case(s)" This reverts commit f69e1603b2ebe69c0a100197cfbcf6f81644b564, indeed too flaky 0:) Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * remove humor from docs/querying/operators.md Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * fix signoff Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * add web/ui missing changes Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * expand limit_ratio test cases, cross-fingering they'll not be flaky Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * remove flaky test Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * add missing warnings.Merge(ws) in instant-query return shortcut Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * add missing LimitK||LimitRatio case to codemirror-promql/src/parser/parser.ts Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * fix ui-lint Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> * actually fix returned warnings :] Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> --------- Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com> Co-authored-by: Julius Volz <julius.volz@gmail.com>
2024-07-03 16:18:57 -04:00
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 2, 2, 1, 1,
1, 2, 1, 1, 1, 0, 1, 1, 2, 3,
3, 4, 4, 6, 7, 4, 1, 1, 1, 1,
2, 3, 3, 3, 3, 3, 3, 3, 3, 6,
1, 3,
}
var yyChk = [...]int16{
-1000, -62, 107, 108, 109, 110, 2, 10, -14, -7,
-13, 64, 65, 81, 66, 67, 84, 85, 86, 68,
12, 49, 50, 53, 69, 18, 70, 88, 71, 72,
73, 74, 75, 92, 95, 96, 76, 77, 97, 98,
90, 89, 13, -63, -14, 10, -40, -34, -38, -41,
-47, -48, -49, -50, -51, -53, -54, -55, -56, -57,
-33, -58, -3, 12, 19, 9, 15, 25, -8, -7,
-46, 97, 98, -12, -59, 64, 65, 66, 67, 68,
69, 70, 71, 72, 73, 74, 75, 76, 77, 41,
59, 13, -57, -13, -15, 20, -16, 12, -10, 2,
25, -21, 2, 41, 61, 42, 43, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 58,
59, 88, 90, 89, 60, 14, 41, 59, 55, 42,
54, 58, -35, -43, 2, 81, 92, 15, -43, -40,
-58, -40, -58, -46, 15, 15, 15, -1, 20, -2,
12, -10, 2, 20, 7, 2, 4, 2, 4, 24,
-36, -37, -44, -39, -52, 80, -36, -36, -36, -36,
-36, -36, -36, -36, -36, -36, -36, -36, -36, -36,
-36, -36, -36, -61, 2, -48, -8, 97, 98, -12,
-58, 70, 69, 15, -32, -9, 2, -29, -31, 95,
96, 19, 9, 41, 59, -60, 2, -58, -48, -8,
97, 98, -58, -58, -58, -58, -58, -58, -43, -35,
-18, 15, 2, -18, -42, 22, -40, 22, 22, 22,
22, -58, 20, 7, 2, -5, 2, 4, 56, 44,
57, -5, 20, -16, 25, 2, 25, 2, -20, 5,
-30, -22, 12, -29, -31, 16, -40, 84, 85, 86,
87, 91, 82, 83, -40, -40, -40, -40, -40, -40,
-40, -40, -40, -40, -40, -40, -40, -40, -40, -40,
-40, -48, 97, 98, -12, 15, -58, 15, 15, 15,
-58, 15, -29, -29, 21, 6, 2, -17, 22, -4,
-6, 25, 2, 64, 80, 65, 81, 66, 67, 68,
82, 83, 84, 85, 86, 12, 87, 49, 50, 53,
69, 18, 70, 88, 91, 71, 72, 73, 74, 75,
95, 96, 61, 76, 77, 97, 98, 90, 89, 22,
7, 7, 20, -2, 25, 2, 25, 2, 26, 26,
-31, 26, 41, 59, -23, 24, 17, -24, 30, 28,
29, 35, 36, 37, 33, 31, 34, 32, 38, -45,
15, -45, -45, -18, -18, -19, -18, -19, 15, 15,
15, -58, 22, 22, -58, 22, -60, 21, 2, 22,
7, 2, -40, -58, -28, 19, -28, 26, -28, -22,
-22, 24, 17, 2, 17, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, -48, -8, 86, 85,
22, 22, -58, 22, 7, 21, 2, 22, -4, 22,
-28, 26, 26, 17, -24, -27, 59, -28, -32, -32,
-32, -29, -25, 14, -25, -27, -25, -27, -11, 101,
102, 103, 104, 22, -48, -45, -45, 7, -58, -28,
-28, -28, -26, -32, 22, -58, 22, 24, 21, 2,
22, 21, -32,
}
var yyDef = [...]int16{
0, -2, 151, 151, 0, 0, 7, 6, 1, 151,
116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
136, 137, 138, 139, 140, 141, 142, 143, 144, 145,
146, 147, 0, 2, -2, 3, 4, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 0, 126, 262, 263, 0, 273, 0, 100,
101, 144, 145, 0, 300, -2, -2, -2, -2, -2,
-2, -2, -2, -2, -2, -2, -2, -2, -2, 256,
257, 0, 5, 115, 0, 150, 153, 0, 157, 161,
274, 162, 166, 48, 48, 48, 48, 48, 48, 48,
48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
48, 0, 84, 85, 0, 0, 0, 0, 0, 0,
0, 0, 0, 25, 26, 0, 0, 0, 74, 0,
22, 98, -2, 99, 0, 0, 0, 0, 104, 106,
0, 110, 114, 148, 0, 154, 0, 160, 0, 165,
0, 47, 56, 52, 53, 49, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 82, 83, 277, 0, 0, 0, 0,
286, 287, 288, 0, 86, 0, 88, 268, 269, 89,
90, 264, 265, 0, 0, 0, 97, 81, 289, 0,
0, 0, 291, 292, 293, 294, 295, 296, 23, 24,
27, 0, 65, 28, 0, 76, 78, 80, 301, 297,
298, 0, 102, 0, 107, 0, 113, 258, 259, 260,
261, 0, 149, 152, 155, 158, 156, 159, 164, 167,
169, 172, 176, 177, 178, 0, 29, 0, 0, 0,
0, 0, -2, -2, 30, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
46, 278, 0, 0, 0, 0, 290, 0, 0, 0,
0, 0, 266, 267, 91, 0, 96, 0, 64, 67,
69, 70, 71, 220, 221, 222, 223, 224, 225, 226,
227, 228, 229, 230, 231, 232, 233, 234, 235, 236,
237, 238, 239, 240, 241, 242, 243, 244, 245, 246,
247, 248, 249, 250, 251, 252, 253, 254, 255, 75,
79, 0, 103, 105, 108, 112, 109, 111, 0, 0,
0, 0, 0, 0, 0, 0, 182, 184, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 57,
0, 58, 59, 50, 51, 54, 276, 55, 0, 0,
0, 0, 279, 280, 0, 87, 0, 93, 95, 62,
0, 68, 77, 0, 168, 270, 170, 0, 173, 0,
0, 0, 180, 185, 181, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
281, 282, 0, 285, 0, 92, 94, 63, 66, 299,
171, 0, 0, 179, 183, 186, 0, 272, 187, 188,
189, 190, 191, 0, 192, 193, 194, 195, 196, 202,
203, 204, 205, 72, 0, 60, 61, 0, 0, 174,
175, 271, 0, 200, 73, 0, 283, 0, 198, 201,
284, 197, 199,
}
var yyTok1 = [...]int8{
1,
}
var yyTok2 = [...]int8{
2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
}
var yyTok3 = [...]int8{
0,
}
var yyErrorMessages = [...]struct {
state int
token int
msg string
}{}
/* parser for yacc output */
var (
yyDebug = 0
yyErrorVerbose = false
)
type yyLexer interface {
Lex(lval *yySymType) int
Error(s string)
}
type yyParser interface {
Parse(yyLexer) int
Lookahead() int
}
type yyParserImpl struct {
lval yySymType
stack [yyInitialStackSize]yySymType
char int
}
func (p *yyParserImpl) Lookahead() int {
return p.char
}
func yyNewParser() yyParser {
return &yyParserImpl{}
}
const yyFlag = -1000
func yyTokname(c int) string {
if c >= 1 && c-1 < len(yyToknames) {
if yyToknames[c-1] != "" {
return yyToknames[c-1]
}
}
return __yyfmt__.Sprintf("tok-%v", c)
}
func yyStatname(s int) string {
if s >= 0 && s < len(yyStatenames) {
if yyStatenames[s] != "" {
return yyStatenames[s]
}
}
return __yyfmt__.Sprintf("state-%v", s)
}
func yyErrorMessage(state, lookAhead int) string {
const TOKSTART = 4
if !yyErrorVerbose {
return "syntax error"
}
for _, e := range yyErrorMessages {
if e.state == state && e.token == lookAhead {
return "syntax error: " + e.msg
}
}
res := "syntax error: unexpected " + yyTokname(lookAhead)
// To match Bison, suggest at most four expected tokens.
expected := make([]int, 0, 4)
// Look for shiftable tokens.
base := int(yyPact[state])
for tok := TOKSTART; tok-1 < len(yyToknames); tok++ {
if n := base + tok; n >= 0 && n < yyLast && int(yyChk[int(yyAct[n])]) == tok {
if len(expected) == cap(expected) {
return res
}
expected = append(expected, tok)
}
}
if yyDef[state] == -2 {
i := 0
for yyExca[i] != -1 || int(yyExca[i+1]) != state {
i += 2
}
// Look for tokens that we accept or reduce.
for i += 2; yyExca[i] >= 0; i += 2 {
tok := int(yyExca[i])
if tok < TOKSTART || yyExca[i+1] == 0 {
continue
}
if len(expected) == cap(expected) {
return res
}
expected = append(expected, tok)
}
// If the default action is to accept or reduce, give up.
if yyExca[i+1] != 0 {
return res
}
}
for i, tok := range expected {
if i == 0 {
res += ", expecting "
} else {
res += " or "
}
res += yyTokname(tok)
}
return res
}
func yylex1(lex yyLexer, lval *yySymType) (char, token int) {
token = 0
char = lex.Lex(lval)
if char <= 0 {
token = int(yyTok1[0])
goto out
}
if char < len(yyTok1) {
token = int(yyTok1[char])
goto out
}
if char >= yyPrivate {
if char < yyPrivate+len(yyTok2) {
token = int(yyTok2[char-yyPrivate])
goto out
}
}
for i := 0; i < len(yyTok3); i += 2 {
token = int(yyTok3[i+0])
if token == char {
token = int(yyTok3[i+1])
goto out
}
}
out:
if token == 0 {
token = int(yyTok2[1]) /* unknown char */
}
if yyDebug >= 3 {
__yyfmt__.Printf("lex %s(%d)\n", yyTokname(token), uint(char))
}
return char, token
}
func yyParse(yylex yyLexer) int {
return yyNewParser().Parse(yylex)
}
func (yyrcvr *yyParserImpl) Parse(yylex yyLexer) int {
var yyn int
var yyVAL yySymType
var yyDollar []yySymType
_ = yyDollar // silence set and not used
yyS := yyrcvr.stack[:]
Nerrs := 0 /* number of errors */
Errflag := 0 /* error recovery flag */
yystate := 0
yyrcvr.char = -1
yytoken := -1 // yyrcvr.char translated into internal numbering
defer func() {
// Make sure we report no lookahead when not parsing.
yystate = -1
yyrcvr.char = -1
yytoken = -1
}()
yyp := -1
goto yystack
ret0:
return 0
ret1:
return 1
yystack:
/* put a state and value onto the stack */
if yyDebug >= 4 {
__yyfmt__.Printf("char %v in %v\n", yyTokname(yytoken), yyStatname(yystate))
}
yyp++
if yyp >= len(yyS) {
nyys := make([]yySymType, len(yyS)*2)
copy(nyys, yyS)
yyS = nyys
}
yyS[yyp] = yyVAL
yyS[yyp].yys = yystate
yynewstate:
yyn = int(yyPact[yystate])
if yyn <= yyFlag {
goto yydefault /* simple state */
}
if yyrcvr.char < 0 {
yyrcvr.char, yytoken = yylex1(yylex, &yyrcvr.lval)
}
yyn += yytoken
if yyn < 0 || yyn >= yyLast {
goto yydefault
}
yyn = int(yyAct[yyn])
if int(yyChk[yyn]) == yytoken { /* valid shift */
yyrcvr.char = -1
yytoken = -1
yyVAL = yyrcvr.lval
yystate = yyn
if Errflag > 0 {
Errflag--
}
goto yystack
}
yydefault:
/* default state action */
yyn = int(yyDef[yystate])
if yyn == -2 {
if yyrcvr.char < 0 {
yyrcvr.char, yytoken = yylex1(yylex, &yyrcvr.lval)
}
/* look through exception table */
xi := 0
for {
if yyExca[xi+0] == -1 && int(yyExca[xi+1]) == yystate {
break
}
xi += 2
}
for xi += 2; ; xi += 2 {
yyn = int(yyExca[xi+0])
if yyn < 0 || yyn == yytoken {
break
}
}
yyn = int(yyExca[xi+1])
if yyn < 0 {
goto ret0
}
}
if yyn == 0 {
/* error ... attempt to resume parsing */
switch Errflag {
case 0: /* brand new error */
yylex.Error(yyErrorMessage(yystate, yytoken))
Nerrs++
if yyDebug >= 1 {
__yyfmt__.Printf("%s", yyStatname(yystate))
__yyfmt__.Printf(" saw %s\n", yyTokname(yytoken))
}
fallthrough
case 1, 2: /* incompletely recovered error ... try again */
Errflag = 3
/* find a state where "error" is a legal shift action */
for yyp >= 0 {
yyn = int(yyPact[yyS[yyp].yys]) + yyErrCode
if yyn >= 0 && yyn < yyLast {
yystate = int(yyAct[yyn]) /* simulate a shift of "error" */
if int(yyChk[yystate]) == yyErrCode {
goto yystack
}
}
/* the current p has no shift on "error", pop stack */
if yyDebug >= 2 {
__yyfmt__.Printf("error recovery pops state %d\n", yyS[yyp].yys)
}
yyp--
}
/* there is no state on the stack with an error shift ... abort */
goto ret1
case 3: /* no shift yet; clobber input char */
if yyDebug >= 2 {
__yyfmt__.Printf("error recovery discards %s\n", yyTokname(yytoken))
}
if yytoken == yyEofCode {
goto ret1
}
yyrcvr.char = -1
yytoken = -1
goto yynewstate /* try again in the same state */
}
}
/* reduction by production yyn */
if yyDebug >= 2 {
__yyfmt__.Printf("reduce %v in:\n\t%v\n", yyn, yyStatname(yystate))
}
yynt := yyn
yypt := yyp
_ = yypt // guard against "declared and not used"
yyp -= int(yyR2[yyn])
// yyp is now the index of $0. Perform the default action. Iff the
// reduced production is ε, $1 is possibly out of range.
if yyp+1 >= len(yyS) {
nyys := make([]yySymType, len(yyS)*2)
copy(nyys, yyS)
yyS = nyys
}
yyVAL = yyS[yyp+1]
/* consult goto table to find next state */
yyn = int(yyR1[yyn])
yyg := int(yyPgo[yyn])
yyj := yyg + yyS[yyp].yys + 1
if yyj >= yyLast {
yystate = int(yyAct[yyg])
} else {
yystate = int(yyAct[yyj])
if int(yyChk[yystate]) != -yyn {
yystate = int(yyAct[yyg])
}
}
// dummy call; replaced with literal code
switch yynt {
case 1:
yyDollar = yyS[yypt-2 : yypt+1]
{
yylex.(*parser).generatedParserResult = yyDollar[2].labels
}
case 3:
yyDollar = yyS[yypt-2 : yypt+1]
{
yylex.(*parser).addParseErrf(posrange.PositionRange{}, "no expression found in input")
}
case 4:
yyDollar = yyS[yypt-2 : yypt+1]
{
yylex.(*parser).generatedParserResult = yyDollar[2].node
}
case 5:
yyDollar = yyS[yypt-2 : yypt+1]
{
yylex.(*parser).generatedParserResult = yyDollar[2].node
}
case 7:
yyDollar = yyS[yypt-1 : yypt+1]
{
yylex.(*parser).unexpected("", "")
}
Add anchored and smoothed to vector selectors. (#16457) * Add anchored and smoothed to vector selectors. This adds "anchored" and "smoothed" keywords that can be used following a matrix selector. "Anchored" selects the last point before the range (or the first one after the range) and adds it at the boundary of the matrix selector. "Smoothed" applies linear interpolation at the edges using the points around the edges. In the absence of a point before or after the edge, the first or the last point is added to the edge, without interpolation. *Exemple usage* * `increase(caddy_http_requests_total[5m] anchored)` (equivalent of *caddy_http_requests_total - caddy_http_requests_total offset 5m* but takes counter reset into consideration) * `rate(caddy_http_requests_total[step()] smoothed)` Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Update docs/feature_flags.md Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> * Smoothed/Anchored rate: Add more tests Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Anchored/Smoothed modifier: error out with histograms Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> --------- Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
2025-09-25 05:34:59 -04:00
case 23:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.node = yylex.(*parser).newAggregateExpr(yyDollar[1].item, yyDollar[2].node, yyDollar[3].node, false)
}
Add anchored and smoothed to vector selectors. (#16457) * Add anchored and smoothed to vector selectors. This adds "anchored" and "smoothed" keywords that can be used following a matrix selector. "Anchored" selects the last point before the range (or the first one after the range) and adds it at the boundary of the matrix selector. "Smoothed" applies linear interpolation at the edges using the points around the edges. In the absence of a point before or after the edge, the first or the last point is added to the edge, without interpolation. *Exemple usage* * `increase(caddy_http_requests_total[5m] anchored)` (equivalent of *caddy_http_requests_total - caddy_http_requests_total offset 5m* but takes counter reset into consideration) * `rate(caddy_http_requests_total[step()] smoothed)` Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Update docs/feature_flags.md Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> * Smoothed/Anchored rate: Add more tests Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Anchored/Smoothed modifier: error out with histograms Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> --------- Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
2025-09-25 05:34:59 -04:00
case 24:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.node = yylex.(*parser).newAggregateExpr(yyDollar[1].item, yyDollar[3].node, yyDollar[2].node, false)
}
Add anchored and smoothed to vector selectors. (#16457) * Add anchored and smoothed to vector selectors. This adds "anchored" and "smoothed" keywords that can be used following a matrix selector. "Anchored" selects the last point before the range (or the first one after the range) and adds it at the boundary of the matrix selector. "Smoothed" applies linear interpolation at the edges using the points around the edges. In the absence of a point before or after the edge, the first or the last point is added to the edge, without interpolation. *Exemple usage* * `increase(caddy_http_requests_total[5m] anchored)` (equivalent of *caddy_http_requests_total - caddy_http_requests_total offset 5m* but takes counter reset into consideration) * `rate(caddy_http_requests_total[step()] smoothed)` Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Update docs/feature_flags.md Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> * Smoothed/Anchored rate: Add more tests Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Anchored/Smoothed modifier: error out with histograms Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> --------- Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
2025-09-25 05:34:59 -04:00
case 25:
yyDollar = yyS[yypt-2 : yypt+1]
{
yyVAL.node = yylex.(*parser).newAggregateExpr(yyDollar[1].item, &AggregateExpr{}, yyDollar[2].node, true)
}
Add anchored and smoothed to vector selectors. (#16457) * Add anchored and smoothed to vector selectors. This adds "anchored" and "smoothed" keywords that can be used following a matrix selector. "Anchored" selects the last point before the range (or the first one after the range) and adds it at the boundary of the matrix selector. "Smoothed" applies linear interpolation at the edges using the points around the edges. In the absence of a point before or after the edge, the first or the last point is added to the edge, without interpolation. *Exemple usage* * `increase(caddy_http_requests_total[5m] anchored)` (equivalent of *caddy_http_requests_total - caddy_http_requests_total offset 5m* but takes counter reset into consideration) * `rate(caddy_http_requests_total[step()] smoothed)` Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Update docs/feature_flags.md Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> * Smoothed/Anchored rate: Add more tests Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Anchored/Smoothed modifier: error out with histograms Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> --------- Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
2025-09-25 05:34:59 -04:00
case 26:
yyDollar = yyS[yypt-2 : yypt+1]
{
yylex.(*parser).unexpected("aggregation", "")
yyVAL.node = yylex.(*parser).newAggregateExpr(yyDollar[1].item, &AggregateExpr{}, Expressions{}, false)
}
Add anchored and smoothed to vector selectors. (#16457) * Add anchored and smoothed to vector selectors. This adds "anchored" and "smoothed" keywords that can be used following a matrix selector. "Anchored" selects the last point before the range (or the first one after the range) and adds it at the boundary of the matrix selector. "Smoothed" applies linear interpolation at the edges using the points around the edges. In the absence of a point before or after the edge, the first or the last point is added to the edge, without interpolation. *Exemple usage* * `increase(caddy_http_requests_total[5m] anchored)` (equivalent of *caddy_http_requests_total - caddy_http_requests_total offset 5m* but takes counter reset into consideration) * `rate(caddy_http_requests_total[step()] smoothed)` Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Update docs/feature_flags.md Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> * Smoothed/Anchored rate: Add more tests Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Anchored/Smoothed modifier: error out with histograms Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> --------- Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
2025-09-25 05:34:59 -04:00
case 27:
yyDollar = yyS[yypt-2 : yypt+1]
{
yyVAL.node = &AggregateExpr{
Grouping: yyDollar[2].strings,
}
}
Add anchored and smoothed to vector selectors. (#16457) * Add anchored and smoothed to vector selectors. This adds "anchored" and "smoothed" keywords that can be used following a matrix selector. "Anchored" selects the last point before the range (or the first one after the range) and adds it at the boundary of the matrix selector. "Smoothed" applies linear interpolation at the edges using the points around the edges. In the absence of a point before or after the edge, the first or the last point is added to the edge, without interpolation. *Exemple usage* * `increase(caddy_http_requests_total[5m] anchored)` (equivalent of *caddy_http_requests_total - caddy_http_requests_total offset 5m* but takes counter reset into consideration) * `rate(caddy_http_requests_total[step()] smoothed)` Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Update docs/feature_flags.md Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> * Smoothed/Anchored rate: Add more tests Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Anchored/Smoothed modifier: error out with histograms Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> --------- Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
2025-09-25 05:34:59 -04:00
case 28:
yyDollar = yyS[yypt-2 : yypt+1]
{
yyVAL.node = &AggregateExpr{
Grouping: yyDollar[2].strings,
Without: true,
}
}
case 29:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node)
}
case 30:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node)
}
case 31:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node)
}
case 32:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node)
}
case 33:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node)
}
case 34:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node)
}
case 35:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node)
}
case 36:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node)
}
case 37:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node)
}
case 38:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node)
}
case 39:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node)
}
case 40:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node)
}
case 41:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node)
}
case 42:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node)
}
Add anchored and smoothed to vector selectors. (#16457) * Add anchored and smoothed to vector selectors. This adds "anchored" and "smoothed" keywords that can be used following a matrix selector. "Anchored" selects the last point before the range (or the first one after the range) and adds it at the boundary of the matrix selector. "Smoothed" applies linear interpolation at the edges using the points around the edges. In the absence of a point before or after the edge, the first or the last point is added to the edge, without interpolation. *Exemple usage* * `increase(caddy_http_requests_total[5m] anchored)` (equivalent of *caddy_http_requests_total - caddy_http_requests_total offset 5m* but takes counter reset into consideration) * `rate(caddy_http_requests_total[step()] smoothed)` Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Update docs/feature_flags.md Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> * Smoothed/Anchored rate: Add more tests Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Anchored/Smoothed modifier: error out with histograms Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> --------- Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
2025-09-25 05:34:59 -04:00
case 43:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node)
}
case 44:
Add anchored and smoothed to vector selectors. (#16457) * Add anchored and smoothed to vector selectors. This adds "anchored" and "smoothed" keywords that can be used following a matrix selector. "Anchored" selects the last point before the range (or the first one after the range) and adds it at the boundary of the matrix selector. "Smoothed" applies linear interpolation at the edges using the points around the edges. In the absence of a point before or after the edge, the first or the last point is added to the edge, without interpolation. *Exemple usage* * `increase(caddy_http_requests_total[5m] anchored)` (equivalent of *caddy_http_requests_total - caddy_http_requests_total offset 5m* but takes counter reset into consideration) * `rate(caddy_http_requests_total[step()] smoothed)` Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Update docs/feature_flags.md Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> * Smoothed/Anchored rate: Add more tests Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Anchored/Smoothed modifier: error out with histograms Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> --------- Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
2025-09-25 05:34:59 -04:00
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node)
}
case 45:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node)
}
Add anchored and smoothed to vector selectors. (#16457) * Add anchored and smoothed to vector selectors. This adds "anchored" and "smoothed" keywords that can be used following a matrix selector. "Anchored" selects the last point before the range (or the first one after the range) and adds it at the boundary of the matrix selector. "Smoothed" applies linear interpolation at the edges using the points around the edges. In the absence of a point before or after the edge, the first or the last point is added to the edge, without interpolation. *Exemple usage* * `increase(caddy_http_requests_total[5m] anchored)` (equivalent of *caddy_http_requests_total - caddy_http_requests_total offset 5m* but takes counter reset into consideration) * `rate(caddy_http_requests_total[step()] smoothed)` Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Update docs/feature_flags.md Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> * Smoothed/Anchored rate: Add more tests Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Anchored/Smoothed modifier: error out with histograms Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> --------- Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
2025-09-25 05:34:59 -04:00
case 46:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node)
}
case 48:
yyDollar = yyS[yypt-0 : yypt+1]
{
yyVAL.node = &BinaryExpr{
VectorMatching: &VectorMatching{Card: CardOneToOne},
}
}
case 49:
yyDollar = yyS[yypt-1 : yypt+1]
{
yyVAL.node = &BinaryExpr{
VectorMatching: &VectorMatching{Card: CardOneToOne},
ReturnBool: true,
}
}
case 50:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.node = yyDollar[1].node
yyVAL.node.(*BinaryExpr).VectorMatching.MatchingLabels = yyDollar[3].strings
}
case 51:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.node = yyDollar[1].node
yyVAL.node.(*BinaryExpr).VectorMatching.MatchingLabels = yyDollar[3].strings
yyVAL.node.(*BinaryExpr).VectorMatching.On = true
}
case 54:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.node = yyDollar[1].node
yyVAL.node.(*BinaryExpr).VectorMatching.Card = CardManyToOne
yyVAL.node.(*BinaryExpr).VectorMatching.Include = yyDollar[3].strings
}
case 55:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.node = yyDollar[1].node
yyVAL.node.(*BinaryExpr).VectorMatching.Card = CardOneToMany
yyVAL.node.(*BinaryExpr).VectorMatching.Include = yyDollar[3].strings
}
case 57:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.node = yyDollar[1].node
fill := yyDollar[3].node.(*NumberLiteral).Val
yyVAL.node.(*BinaryExpr).VectorMatching.FillValues.LHS = &fill
yyVAL.node.(*BinaryExpr).VectorMatching.FillValues.RHS = &fill
}
case 58:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.node = yyDollar[1].node
fill := yyDollar[3].node.(*NumberLiteral).Val
yyVAL.node.(*BinaryExpr).VectorMatching.FillValues.LHS = &fill
}
case 59:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.node = yyDollar[1].node
fill := yyDollar[3].node.(*NumberLiteral).Val
yyVAL.node.(*BinaryExpr).VectorMatching.FillValues.RHS = &fill
}
case 60:
yyDollar = yyS[yypt-5 : yypt+1]
{
yyVAL.node = yyDollar[1].node
fill_left := yyDollar[3].node.(*NumberLiteral).Val
fill_right := yyDollar[5].node.(*NumberLiteral).Val
yyVAL.node.(*BinaryExpr).VectorMatching.FillValues.LHS = &fill_left
yyVAL.node.(*BinaryExpr).VectorMatching.FillValues.RHS = &fill_right
}
case 61:
yyDollar = yyS[yypt-5 : yypt+1]
{
fill_right := yyDollar[3].node.(*NumberLiteral).Val
fill_left := yyDollar[5].node.(*NumberLiteral).Val
yyVAL.node.(*BinaryExpr).VectorMatching.FillValues.LHS = &fill_left
yyVAL.node.(*BinaryExpr).VectorMatching.FillValues.RHS = &fill_right
}
case 62:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.strings = yyDollar[2].strings
}
case 63:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.strings = yyDollar[2].strings
}
case 64:
yyDollar = yyS[yypt-2 : yypt+1]
{
yyVAL.strings = []string{}
}
case 65:
yyDollar = yyS[yypt-1 : yypt+1]
{
yylex.(*parser).unexpected("grouping opts", "\"(\"")
yyVAL.strings = nil
}
case 66:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.strings = append(yyDollar[1].strings, yyDollar[3].item.Val)
}
case 67:
yyDollar = yyS[yypt-1 : yypt+1]
{
yyVAL.strings = []string{yyDollar[1].item.Val}
}
case 68:
yyDollar = yyS[yypt-2 : yypt+1]
{
yylex.(*parser).unexpected("grouping opts", "\",\" or \")\"")
yyVAL.strings = yyDollar[1].strings
}
case 69:
yyDollar = yyS[yypt-1 : yypt+1]
{
if !model.UTF8Validation.IsValidLabelName(yyDollar[1].item.Val) {
yylex.(*parser).addParseErrf(yyDollar[1].item.PositionRange(), "invalid label name for grouping: %q", yyDollar[1].item.Val)
}
yyVAL.item = yyDollar[1].item
}
case 70:
yyDollar = yyS[yypt-1 : yypt+1]
{
unquoted := yylex.(*parser).unquoteString(yyDollar[1].item.Val)
if !model.UTF8Validation.IsValidLabelName(unquoted) {
yylex.(*parser).addParseErrf(yyDollar[1].item.PositionRange(), "invalid label name for grouping: %q", unquoted)
}
yyVAL.item = yyDollar[1].item
yyVAL.item.Pos++
yyVAL.item.Val = unquoted
}
case 71:
yyDollar = yyS[yypt-1 : yypt+1]
{
yylex.(*parser).unexpected("grouping opts", "label")
yyVAL.item = Item{}
}
case 72:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.node = yyDollar[2].node.(*NumberLiteral)
}
case 73:
yyDollar = yyS[yypt-4 : yypt+1]
{
nl := yyDollar[3].node.(*NumberLiteral)
if yyDollar[2].item.Typ == SUB {
nl.Val *= -1
}
nl.PosRange.Start = yyDollar[2].item.Pos
yyVAL.node = nl
}
case 74:
yyDollar = yyS[yypt-2 : yypt+1]
{
fn, exist := getFunction(yyDollar[1].item.Val, yylex.(*parser).functions)
if !exist {
yylex.(*parser).addParseErrf(yyDollar[1].item.PositionRange(), "unknown function with name %q", yyDollar[1].item.Val)
}
if fn != nil && fn.Experimental && !yylex.(*parser).options.EnableExperimentalFunctions {
yylex.(*parser).addParseErrf(yyDollar[1].item.PositionRange(), "function %q is not enabled", yyDollar[1].item.Val)
}
yyVAL.node = &Call{
Func: fn,
Args: yyDollar[2].node.(Expressions),
PosRange: posrange.PositionRange{
Start: yyDollar[1].item.Pos,
End: yylex.(*parser).lastClosing,
},
}
}
case 75:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.node = yyDollar[2].node
}
case 76:
yyDollar = yyS[yypt-2 : yypt+1]
{
yyVAL.node = Expressions{}
}
case 77:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.node = append(yyDollar[1].node.(Expressions), yyDollar[3].node.(Expr))
}
case 78:
yyDollar = yyS[yypt-1 : yypt+1]
{
yyVAL.node = Expressions{yyDollar[1].node.(Expr)}
}
case 79:
yyDollar = yyS[yypt-2 : yypt+1]
{
yylex.(*parser).addParseErrf(yyDollar[2].item.PositionRange(), "trailing commas not allowed in function call args")
yyVAL.node = yyDollar[1].node
}
case 80:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.node = &ParenExpr{Expr: yyDollar[2].node.(Expr), PosRange: mergeRanges(&yyDollar[1].item, &yyDollar[3].item)}
}
case 81:
yyDollar = yyS[yypt-1 : yypt+1]
{
if numLit, ok := yyDollar[1].node.(*NumberLiteral); ok {
if numLit.Val <= 0 {
yylex.(*parser).addParseErrf(numLit.PositionRange(), "duration must be greater than 0")
yyVAL.node = &NumberLiteral{Val: 0} // Return 0 on error.
break
}
yyVAL.node = yyDollar[1].node
break
}
yyVAL.node = yyDollar[1].node
}
case 82:
yyDollar = yyS[yypt-3 : yypt+1]
{
if numLit, ok := yyDollar[3].node.(*NumberLiteral); ok {
yylex.(*parser).addOffset(yyDollar[1].node, time.Duration(math.Round(numLit.Val*float64(time.Second))))
yyVAL.node = yyDollar[1].node
break
}
yylex.(*parser).addOffsetExpr(yyDollar[1].node, yyDollar[3].node.(*DurationExpr))
yyVAL.node = yyDollar[1].node
}
case 83:
yyDollar = yyS[yypt-3 : yypt+1]
{
yylex.(*parser).unexpected("offset", "number, duration, step(), or range()")
yyVAL.node = yyDollar[1].node
}
case 84:
Add anchored and smoothed to vector selectors. (#16457) * Add anchored and smoothed to vector selectors. This adds "anchored" and "smoothed" keywords that can be used following a matrix selector. "Anchored" selects the last point before the range (or the first one after the range) and adds it at the boundary of the matrix selector. "Smoothed" applies linear interpolation at the edges using the points around the edges. In the absence of a point before or after the edge, the first or the last point is added to the edge, without interpolation. *Exemple usage* * `increase(caddy_http_requests_total[5m] anchored)` (equivalent of *caddy_http_requests_total - caddy_http_requests_total offset 5m* but takes counter reset into consideration) * `rate(caddy_http_requests_total[step()] smoothed)` Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Update docs/feature_flags.md Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> * Smoothed/Anchored rate: Add more tests Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Anchored/Smoothed modifier: error out with histograms Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> --------- Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
2025-09-25 05:34:59 -04:00
yyDollar = yyS[yypt-2 : yypt+1]
{
yylex.(*parser).setAnchored(yyDollar[1].node)
}
case 85:
Add anchored and smoothed to vector selectors. (#16457) * Add anchored and smoothed to vector selectors. This adds "anchored" and "smoothed" keywords that can be used following a matrix selector. "Anchored" selects the last point before the range (or the first one after the range) and adds it at the boundary of the matrix selector. "Smoothed" applies linear interpolation at the edges using the points around the edges. In the absence of a point before or after the edge, the first or the last point is added to the edge, without interpolation. *Exemple usage* * `increase(caddy_http_requests_total[5m] anchored)` (equivalent of *caddy_http_requests_total - caddy_http_requests_total offset 5m* but takes counter reset into consideration) * `rate(caddy_http_requests_total[step()] smoothed)` Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Update docs/feature_flags.md Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> * Smoothed/Anchored rate: Add more tests Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Anchored/Smoothed modifier: error out with histograms Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> --------- Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
2025-09-25 05:34:59 -04:00
yyDollar = yyS[yypt-2 : yypt+1]
{
yylex.(*parser).setSmoothed(yyDollar[1].node)
}
case 86:
yyDollar = yyS[yypt-3 : yypt+1]
{
yylex.(*parser).setTimestamp(yyDollar[1].node, yyDollar[3].float)
yyVAL.node = yyDollar[1].node
}
case 87:
yyDollar = yyS[yypt-5 : yypt+1]
{
yylex.(*parser).setAtModifierPreprocessor(yyDollar[1].node, yyDollar[3].item)
yyVAL.node = yyDollar[1].node
}
case 88:
yyDollar = yyS[yypt-3 : yypt+1]
{
yylex.(*parser).unexpected("@", "timestamp")
yyVAL.node = yyDollar[1].node
}
case 91:
yyDollar = yyS[yypt-4 : yypt+1]
{
var errMsg string
vs, ok := yyDollar[1].node.(*VectorSelector)
if !ok {
errMsg = "ranges only allowed for vector selectors"
} else if vs.OriginalOffset != 0 {
errMsg = "no offset modifiers allowed before range"
} else if vs.Timestamp != nil {
errMsg = "no @ modifiers allowed before range"
}
if errMsg != "" {
errRange := mergeRanges(&yyDollar[2].item, &yyDollar[4].item)
yylex.(*parser).addParseErrf(errRange, "%s", errMsg)
}
var rangeNl time.Duration
if numLit, ok := yyDollar[3].node.(*NumberLiteral); ok {
rangeNl = time.Duration(math.Round(numLit.Val * float64(time.Second)))
}
rangeExpr, _ := yyDollar[3].node.(*DurationExpr)
yyVAL.node = &MatrixSelector{
VectorSelector: yyDollar[1].node.(Expr),
Range: rangeNl,
RangeExpr: rangeExpr,
EndPos: yylex.(*parser).lastClosing,
}
}
case 92:
yyDollar = yyS[yypt-6 : yypt+1]
{
var rangeNl time.Duration
var stepNl time.Duration
if numLit, ok := yyDollar[3].node.(*NumberLiteral); ok {
rangeNl = time.Duration(math.Round(numLit.Val * float64(time.Second)))
}
rangeExpr, _ := yyDollar[3].node.(*DurationExpr)
if numLit, ok := yyDollar[5].node.(*NumberLiteral); ok {
stepNl = time.Duration(math.Round(numLit.Val * float64(time.Second)))
}
stepExpr, _ := yyDollar[5].node.(*DurationExpr)
yyVAL.node = &SubqueryExpr{
Expr: yyDollar[1].node.(Expr),
Range: rangeNl,
RangeExpr: rangeExpr,
Step: stepNl,
StepExpr: stepExpr,
EndPos: yyDollar[6].item.Pos + 1,
}
}
case 93:
yyDollar = yyS[yypt-5 : yypt+1]
{
var rangeNl time.Duration
if numLit, ok := yyDollar[3].node.(*NumberLiteral); ok {
rangeNl = time.Duration(math.Round(numLit.Val * float64(time.Second)))
}
rangeExpr, _ := yyDollar[3].node.(*DurationExpr)
yyVAL.node = &SubqueryExpr{
Expr: yyDollar[1].node.(Expr),
Range: rangeNl,
RangeExpr: rangeExpr,
EndPos: yyDollar[5].item.Pos + 1,
}
}
case 94:
yyDollar = yyS[yypt-6 : yypt+1]
{
yylex.(*parser).unexpected("subquery selector", "\"]\"")
yyVAL.node = yyDollar[1].node
}
case 95:
yyDollar = yyS[yypt-5 : yypt+1]
{
yylex.(*parser).unexpected("subquery selector", "number, duration, step(), range(), or \"]\"")
yyVAL.node = yyDollar[1].node
}
case 96:
yyDollar = yyS[yypt-4 : yypt+1]
{
yylex.(*parser).unexpected("subquery or range", "\":\" or \"]\"")
yyVAL.node = yyDollar[1].node
}
case 97:
yyDollar = yyS[yypt-3 : yypt+1]
{
yylex.(*parser).unexpected("subquery or range selector", "number, duration, step(), or range()")
yyVAL.node = yyDollar[1].node
}
case 98:
yyDollar = yyS[yypt-2 : yypt+1]
{
if nl, ok := yyDollar[2].node.(*NumberLiteral); ok {
if yyDollar[1].item.Typ == SUB {
nl.Val *= -1
}
nl.PosRange.Start = yyDollar[1].item.Pos
yyVAL.node = nl
} else {
yyVAL.node = &UnaryExpr{Op: yyDollar[1].item.Typ, Expr: yyDollar[2].node.(Expr), StartPos: yyDollar[1].item.Pos}
}
}
case 99:
yyDollar = yyS[yypt-2 : yypt+1]
{
vs := yyDollar[2].node.(*VectorSelector)
vs.PosRange = mergeRanges(&yyDollar[1].item, vs)
vs.Name = yyDollar[1].item.Val
yylex.(*parser).assembleVectorSelector(vs)
yyVAL.node = vs
}
case 100:
yyDollar = yyS[yypt-1 : yypt+1]
{
vs := &VectorSelector{
Name: yyDollar[1].item.Val,
LabelMatchers: []*labels.Matcher{},
PosRange: yyDollar[1].item.PositionRange(),
}
yylex.(*parser).assembleVectorSelector(vs)
yyVAL.node = vs
}
case 101:
yyDollar = yyS[yypt-1 : yypt+1]
{
vs := yyDollar[1].node.(*VectorSelector)
yylex.(*parser).assembleVectorSelector(vs)
yyVAL.node = vs
}
case 102:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.node = &VectorSelector{
LabelMatchers: yyDollar[2].matchers,
PosRange: mergeRanges(&yyDollar[1].item, &yyDollar[3].item),
}
}
case 103:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.node = &VectorSelector{
LabelMatchers: yyDollar[2].matchers,
PosRange: mergeRanges(&yyDollar[1].item, &yyDollar[4].item),
}
}
case 104:
yyDollar = yyS[yypt-2 : yypt+1]
{
yyVAL.node = &VectorSelector{
LabelMatchers: []*labels.Matcher{},
PosRange: mergeRanges(&yyDollar[1].item, &yyDollar[2].item),
}
}
case 105:
yyDollar = yyS[yypt-3 : yypt+1]
{
if yyDollar[1].matchers != nil {
yyVAL.matchers = append(yyDollar[1].matchers, yyDollar[3].matcher)
} else {
yyVAL.matchers = yyDollar[1].matchers
}
}
case 106:
yyDollar = yyS[yypt-1 : yypt+1]
{
yyVAL.matchers = []*labels.Matcher{yyDollar[1].matcher}
}
case 107:
yyDollar = yyS[yypt-2 : yypt+1]
{
yylex.(*parser).unexpected("label matching", "\",\" or \"}\"")
yyVAL.matchers = yyDollar[1].matchers
}
case 108:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.matcher = yylex.(*parser).newLabelMatcher(yyDollar[1].item, yyDollar[2].item, yyDollar[3].item)
}
case 109:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.matcher = yylex.(*parser).newLabelMatcher(yyDollar[1].item, yyDollar[2].item, yyDollar[3].item)
}
case 110:
yyDollar = yyS[yypt-1 : yypt+1]
{
yyVAL.matcher = yylex.(*parser).newMetricNameMatcher(yyDollar[1].item)
}
case 111:
yyDollar = yyS[yypt-3 : yypt+1]
{
yylex.(*parser).unexpected("label matching", "string")
yyVAL.matcher = nil
}
case 112:
yyDollar = yyS[yypt-3 : yypt+1]
{
yylex.(*parser).unexpected("label matching", "string")
yyVAL.matcher = nil
}
case 113:
yyDollar = yyS[yypt-2 : yypt+1]
{
yylex.(*parser).unexpected("label matching", "label matching operator")
yyVAL.matcher = nil
}
case 114:
yyDollar = yyS[yypt-1 : yypt+1]
{
yylex.(*parser).unexpected("label matching", "identifier or \"}\"")
yyVAL.matcher = nil
}
case 115:
yyDollar = yyS[yypt-2 : yypt+1]
{
b := labels.NewBuilder(yyDollar[2].labels)
b.Set(labels.MetricName, yyDollar[1].item.Val)
yyVAL.labels = b.Labels()
}
case 116:
yyDollar = yyS[yypt-1 : yypt+1]
{
yyVAL.labels = yyDollar[1].labels
}
case 148:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.labels = labels.New(yyDollar[2].lblList...)
}
case 149:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.labels = labels.New(yyDollar[2].lblList...)
}
case 150:
yyDollar = yyS[yypt-2 : yypt+1]
{
yyVAL.labels = labels.New()
}
case 151:
yyDollar = yyS[yypt-0 : yypt+1]
{
yyVAL.labels = labels.New()
}
case 152:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.lblList = append(yyDollar[1].lblList, yyDollar[3].label)
}
case 153:
yyDollar = yyS[yypt-1 : yypt+1]
{
yyVAL.lblList = []labels.Label{yyDollar[1].label}
}
case 154:
yyDollar = yyS[yypt-2 : yypt+1]
{
yylex.(*parser).unexpected("label set", "\",\" or \"}\"")
yyVAL.lblList = yyDollar[1].lblList
}
case 155:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.label = labels.Label{Name: yyDollar[1].item.Val, Value: yylex.(*parser).unquoteString(yyDollar[3].item.Val)}
}
case 156:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.label = labels.Label{Name: yyDollar[1].item.Val, Value: yylex.(*parser).unquoteString(yyDollar[3].item.Val)}
}
case 157:
yyDollar = yyS[yypt-1 : yypt+1]
{
yyVAL.label = labels.Label{Name: labels.MetricName, Value: yyDollar[1].item.Val}
}
case 158:
yyDollar = yyS[yypt-3 : yypt+1]
{
yylex.(*parser).unexpected("label set", "string")
yyVAL.label = labels.Label{}
}
case 159:
yyDollar = yyS[yypt-3 : yypt+1]
{
yylex.(*parser).unexpected("label set", "string")
yyVAL.label = labels.Label{}
}
case 160:
yyDollar = yyS[yypt-2 : yypt+1]
{
yylex.(*parser).unexpected("label set", "\"=\"")
yyVAL.label = labels.Label{}
}
case 161:
yyDollar = yyS[yypt-1 : yypt+1]
{
yylex.(*parser).unexpected("label set", "identifier or \"}\"")
yyVAL.label = labels.Label{}
}
case 162:
yyDollar = yyS[yypt-2 : yypt+1]
{
yylex.(*parser).generatedParserResult = &seriesDescription{
labels: yyDollar[1].labels,
values: yyDollar[2].series,
}
}
case 163:
yyDollar = yyS[yypt-0 : yypt+1]
{
yyVAL.series = []SequenceValue{}
}
case 164:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.series = append(yyDollar[1].series, yyDollar[3].series...)
}
case 165:
yyDollar = yyS[yypt-2 : yypt+1]
{
yyVAL.series = yyDollar[1].series
}
case 166:
yyDollar = yyS[yypt-1 : yypt+1]
{
yylex.(*parser).unexpected("series values", "")
yyVAL.series = nil
}
case 167:
yyDollar = yyS[yypt-1 : yypt+1]
{
yyVAL.series = []SequenceValue{{Omitted: true}}
}
case 168:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.series = []SequenceValue{}
for i := uint64(0); i < yyDollar[3].uint; i++ {
yyVAL.series = append(yyVAL.series, SequenceValue{Omitted: true})
}
}
case 169:
yyDollar = yyS[yypt-1 : yypt+1]
{
yyVAL.series = []SequenceValue{{Value: yyDollar[1].float}}
}
case 170:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.series = []SequenceValue{}
// Add an additional value for time 0, which we ignore in tests.
for i := uint64(0); i <= yyDollar[3].uint; i++ {
yyVAL.series = append(yyVAL.series, SequenceValue{Value: yyDollar[1].float})
}
}
case 171:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.series = []SequenceValue{}
// Add an additional value for time 0, which we ignore in tests.
for i := uint64(0); i <= yyDollar[4].uint; i++ {
yyVAL.series = append(yyVAL.series, SequenceValue{Value: yyDollar[1].float})
yyDollar[1].float += yyDollar[2].float
}
}
case 172:
yyDollar = yyS[yypt-1 : yypt+1]
{
yyVAL.series = []SequenceValue{yylex.(*parser).newHistogramSequenceValue(yyDollar[1].histogram)}
}
case 173:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.series = []SequenceValue{}
// Add an additional value for time 0, which we ignore in tests.
sv := yylex.(*parser).newHistogramSequenceValue(yyDollar[1].histogram)
for i := uint64(0); i <= yyDollar[3].uint; i++ {
yyVAL.series = append(yyVAL.series, sv)
//$1 += $2
}
}
case 174:
yyDollar = yyS[yypt-5 : yypt+1]
{
val, err := yylex.(*parser).histogramsIncreaseSeries(yyDollar[1].histogram, yyDollar[3].histogram, yyDollar[5].uint)
if err != nil {
yylex.(*parser).addSemanticError(err)
}
yyVAL.series = val
}
case 175:
yyDollar = yyS[yypt-5 : yypt+1]
{
val, err := yylex.(*parser).histogramsDecreaseSeries(yyDollar[1].histogram, yyDollar[3].histogram, yyDollar[5].uint)
if err != nil {
yylex.(*parser).addSemanticError(err)
}
yyVAL.series = val
}
case 176:
yyDollar = yyS[yypt-1 : yypt+1]
{
if yyDollar[1].item.Val != "stale" {
yylex.(*parser).unexpected("series values", "number or \"stale\"")
}
yyVAL.float = math.Float64frombits(value.StaleNaN)
}
case 179:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.histogram = yylex.(*parser).buildHistogramFromMap(&yyDollar[2].descriptors)
}
case 180:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.histogram = yylex.(*parser).buildHistogramFromMap(&yyDollar[2].descriptors)
}
case 181:
yyDollar = yyS[yypt-3 : yypt+1]
{
m := yylex.(*parser).newMap()
yyVAL.histogram = yylex.(*parser).buildHistogramFromMap(&m)
}
case 182:
yyDollar = yyS[yypt-2 : yypt+1]
{
m := yylex.(*parser).newMap()
yyVAL.histogram = yylex.(*parser).buildHistogramFromMap(&m)
}
case 183:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.descriptors = *(yylex.(*parser).mergeMaps(&yyDollar[1].descriptors, &yyDollar[3].descriptors))
}
case 184:
yyDollar = yyS[yypt-1 : yypt+1]
{
yyVAL.descriptors = yyDollar[1].descriptors
}
case 185:
yyDollar = yyS[yypt-2 : yypt+1]
{
yylex.(*parser).unexpected("histogram description", "histogram description key, e.g. buckets:[5 10 7]")
}
case 186:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.descriptors = yylex.(*parser).newMap()
yyVAL.descriptors["schema"] = yyDollar[3].int
}
case 187:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.descriptors = yylex.(*parser).newMap()
yyVAL.descriptors["sum"] = yyDollar[3].float
}
case 188:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.descriptors = yylex.(*parser).newMap()
yyVAL.descriptors["count"] = yyDollar[3].float
}
case 189:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.descriptors = yylex.(*parser).newMap()
yyVAL.descriptors["z_bucket"] = yyDollar[3].float
}
case 190:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.descriptors = yylex.(*parser).newMap()
yyVAL.descriptors["z_bucket_w"] = yyDollar[3].float
}
case 191:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.descriptors = yylex.(*parser).newMap()
yyVAL.descriptors["custom_values"] = yyDollar[3].bucket_set
}
case 192:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.descriptors = yylex.(*parser).newMap()
yyVAL.descriptors["buckets"] = yyDollar[3].bucket_set
}
case 193:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.descriptors = yylex.(*parser).newMap()
yyVAL.descriptors["offset"] = yyDollar[3].int
}
case 194:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.descriptors = yylex.(*parser).newMap()
yyVAL.descriptors["n_buckets"] = yyDollar[3].bucket_set
}
case 195:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.descriptors = yylex.(*parser).newMap()
yyVAL.descriptors["n_offset"] = yyDollar[3].int
}
case 196:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.descriptors = yylex.(*parser).newMap()
yyVAL.descriptors["counter_reset_hint"] = yyDollar[3].item
}
case 197:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.bucket_set = yyDollar[2].bucket_set
}
case 198:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.bucket_set = yyDollar[2].bucket_set
}
case 199:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.bucket_set = append(yyDollar[1].bucket_set, yyDollar[3].float)
}
case 200:
yyDollar = yyS[yypt-1 : yypt+1]
{
yyVAL.bucket_set = []float64{yyDollar[1].float}
}
case 262:
yyDollar = yyS[yypt-1 : yypt+1]
{
yyVAL.node = &NumberLiteral{
Val: yylex.(*parser).number(yyDollar[1].item.Val),
PosRange: yyDollar[1].item.PositionRange(),
}
}
case 263:
yyDollar = yyS[yypt-1 : yypt+1]
{
var err error
var dur time.Duration
dur, err = parseDuration(yyDollar[1].item.Val)
if err != nil {
yylex.(*parser).addParseErr(yyDollar[1].item.PositionRange(), err)
}
yyVAL.node = &NumberLiteral{
Val: dur.Seconds(),
PosRange: yyDollar[1].item.PositionRange(),
Duration: true,
}
}
case 264:
yyDollar = yyS[yypt-1 : yypt+1]
{
yyVAL.float = yylex.(*parser).number(yyDollar[1].item.Val)
}
case 265:
yyDollar = yyS[yypt-1 : yypt+1]
{
var err error
var dur time.Duration
dur, err = parseDuration(yyDollar[1].item.Val)
if err != nil {
yylex.(*parser).addParseErr(yyDollar[1].item.PositionRange(), err)
}
yyVAL.float = dur.Seconds()
}
case 266:
yyDollar = yyS[yypt-2 : yypt+1]
{
yyVAL.float = yyDollar[2].float
}
case 267:
yyDollar = yyS[yypt-2 : yypt+1]
{
yyVAL.float = -yyDollar[2].float
}
case 270:
yyDollar = yyS[yypt-1 : yypt+1]
{
var err error
yyVAL.uint, err = strconv.ParseUint(yyDollar[1].item.Val, 10, 64)
if err != nil {
yylex.(*parser).addParseErrf(yyDollar[1].item.PositionRange(), "invalid repetition in series values: %s", err)
}
}
case 271:
yyDollar = yyS[yypt-2 : yypt+1]
{
yyVAL.int = -int64(yyDollar[2].uint)
}
case 272:
yyDollar = yyS[yypt-1 : yypt+1]
{
yyVAL.int = int64(yyDollar[1].uint)
}
case 273:
yyDollar = yyS[yypt-1 : yypt+1]
{
yyVAL.node = &StringLiteral{
Val: yylex.(*parser).unquoteString(yyDollar[1].item.Val),
PosRange: yyDollar[1].item.PositionRange(),
}
}
case 274:
yyDollar = yyS[yypt-1 : yypt+1]
{
yyVAL.item = Item{
Typ: METRIC_IDENTIFIER,
Pos: yyDollar[1].item.PositionRange().Start,
Val: yylex.(*parser).unquoteString(yyDollar[1].item.Val),
}
}
case 275:
yyDollar = yyS[yypt-0 : yypt+1]
{
yyVAL.strings = nil
}
case 277:
yyDollar = yyS[yypt-1 : yypt+1]
{
nl := yyDollar[1].node.(*NumberLiteral)
if nl.Val > 1<<63/1e9 || nl.Val < -(1<<63)/1e9 {
yylex.(*parser).addParseErrf(nl.PosRange, "duration out of range")
yyVAL.node = &NumberLiteral{Val: 0}
break
}
yyVAL.node = nl
}
case 278:
yyDollar = yyS[yypt-2 : yypt+1]
{
nl := yyDollar[2].node.(*NumberLiteral)
if yyDollar[1].item.Typ == SUB {
nl.Val *= -1
}
if nl.Val > 1<<63/1e9 || nl.Val < -(1<<63)/1e9 {
yylex.(*parser).addParseErrf(yyDollar[1].item.PositionRange(), "duration out of range")
yyVAL.node = &NumberLiteral{Val: 0}
break
}
nl.PosRange.Start = yyDollar[1].item.Pos
yyVAL.node = nl
}
case 279:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.node = &DurationExpr{
Op: STEP,
StartPos: yyDollar[1].item.PositionRange().Start,
EndPos: yyDollar[3].item.PositionRange().End,
}
}
case 280:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.node = &DurationExpr{
Op: RANGE,
StartPos: yyDollar[1].item.PositionRange().Start,
EndPos: yyDollar[3].item.PositionRange().End,
}
}
case 281:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.node = &DurationExpr{
Op: yyDollar[1].item.Typ,
RHS: &DurationExpr{
Op: STEP,
StartPos: yyDollar[2].item.PositionRange().Start,
EndPos: yyDollar[4].item.PositionRange().End,
},
StartPos: yyDollar[1].item.Pos,
}
}
case 282:
yyDollar = yyS[yypt-4 : yypt+1]
{
yyVAL.node = &DurationExpr{
Op: yyDollar[1].item.Typ,
RHS: &DurationExpr{
Op: RANGE,
StartPos: yyDollar[2].item.PositionRange().Start,
EndPos: yyDollar[4].item.PositionRange().End,
},
StartPos: yyDollar[1].item.Pos,
}
}
case 283:
yyDollar = yyS[yypt-6 : yypt+1]
{
yyVAL.node = &DurationExpr{
Op: yyDollar[1].item.Typ,
StartPos: yyDollar[1].item.PositionRange().Start,
EndPos: yyDollar[6].item.PositionRange().End,
LHS: yyDollar[3].node.(Expr),
RHS: yyDollar[5].node.(Expr),
}
}
case 284:
yyDollar = yyS[yypt-7 : yypt+1]
{
yyVAL.node = &DurationExpr{
Op: yyDollar[1].item.Typ,
StartPos: yyDollar[1].item.Pos,
EndPos: yyDollar[6].node.PositionRange().End,
RHS: &DurationExpr{
Op: yyDollar[2].item.Typ,
StartPos: yyDollar[2].item.PositionRange().Start,
EndPos: yyDollar[6].node.PositionRange().End,
LHS: yyDollar[4].node.(Expr),
RHS: yyDollar[6].node.(Expr),
},
}
}
case 285:
yyDollar = yyS[yypt-4 : yypt+1]
{
de := yyDollar[3].node.(*DurationExpr)
de.Wrapped = true
if yyDollar[1].item.Typ == SUB {
yyVAL.node = &DurationExpr{
Op: SUB,
RHS: de,
StartPos: yyDollar[1].item.Pos,
}
break
}
yyVAL.node = yyDollar[3].node
}
case 289:
yyDollar = yyS[yypt-1 : yypt+1]
{
nl := yyDollar[1].node.(*NumberLiteral)
if nl.Val > 1<<63/1e9 || nl.Val < -(1<<63)/1e9 {
yylex.(*parser).addParseErrf(nl.PosRange, "duration out of range")
yyVAL.node = &NumberLiteral{Val: 0}
break
}
yyVAL.node = nl
}
case 290:
yyDollar = yyS[yypt-2 : yypt+1]
{
switch expr := yyDollar[2].node.(type) {
case *NumberLiteral:
if yyDollar[1].item.Typ == SUB {
expr.Val *= -1
}
if expr.Val > 1<<63/1e9 || expr.Val < -(1<<63)/1e9 {
yylex.(*parser).addParseErrf(yyDollar[1].item.PositionRange(), "duration out of range")
yyVAL.node = &NumberLiteral{Val: 0}
break
}
expr.PosRange.Start = yyDollar[1].item.Pos
yyVAL.node = expr
break
case *DurationExpr:
if yyDollar[1].item.Typ == SUB {
yyVAL.node = &DurationExpr{
Op: SUB,
RHS: expr,
StartPos: yyDollar[1].item.Pos,
}
break
}
yyVAL.node = expr
break
default:
yylex.(*parser).addParseErrf(yyDollar[1].item.PositionRange(), "expected number literal or duration expression")
yyVAL.node = &NumberLiteral{Val: 0}
break
}
}
case 291:
yyDollar = yyS[yypt-3 : yypt+1]
{
yylex.(*parser).experimentalDurationExpr(yyDollar[1].node.(Expr))
yyVAL.node = &DurationExpr{Op: ADD, LHS: yyDollar[1].node.(Expr), RHS: yyDollar[3].node.(Expr)}
}
case 292:
yyDollar = yyS[yypt-3 : yypt+1]
{
yylex.(*parser).experimentalDurationExpr(yyDollar[1].node.(Expr))
yyVAL.node = &DurationExpr{Op: SUB, LHS: yyDollar[1].node.(Expr), RHS: yyDollar[3].node.(Expr)}
}
case 293:
yyDollar = yyS[yypt-3 : yypt+1]
{
yylex.(*parser).experimentalDurationExpr(yyDollar[1].node.(Expr))
yyVAL.node = &DurationExpr{Op: MUL, LHS: yyDollar[1].node.(Expr), RHS: yyDollar[3].node.(Expr)}
}
case 294:
yyDollar = yyS[yypt-3 : yypt+1]
{
yylex.(*parser).experimentalDurationExpr(yyDollar[1].node.(Expr))
if nl, ok := yyDollar[3].node.(*NumberLiteral); ok && nl.Val == 0 {
yylex.(*parser).addParseErrf(yyDollar[2].item.PositionRange(), "division by zero")
yyVAL.node = &NumberLiteral{Val: 0}
break
}
yyVAL.node = &DurationExpr{Op: DIV, LHS: yyDollar[1].node.(Expr), RHS: yyDollar[3].node.(Expr)}
}
case 295:
yyDollar = yyS[yypt-3 : yypt+1]
{
yylex.(*parser).experimentalDurationExpr(yyDollar[1].node.(Expr))
if nl, ok := yyDollar[3].node.(*NumberLiteral); ok && nl.Val == 0 {
yylex.(*parser).addParseErrf(yyDollar[2].item.PositionRange(), "modulo by zero")
yyVAL.node = &NumberLiteral{Val: 0}
break
}
yyVAL.node = &DurationExpr{Op: MOD, LHS: yyDollar[1].node.(Expr), RHS: yyDollar[3].node.(Expr)}
}
case 296:
yyDollar = yyS[yypt-3 : yypt+1]
{
yylex.(*parser).experimentalDurationExpr(yyDollar[1].node.(Expr))
yyVAL.node = &DurationExpr{Op: POW, LHS: yyDollar[1].node.(Expr), RHS: yyDollar[3].node.(Expr)}
}
case 297:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.node = &DurationExpr{
Op: STEP,
StartPos: yyDollar[1].item.PositionRange().Start,
EndPos: yyDollar[3].item.PositionRange().End,
}
}
case 298:
yyDollar = yyS[yypt-3 : yypt+1]
{
yyVAL.node = &DurationExpr{
Op: RANGE,
StartPos: yyDollar[1].item.PositionRange().Start,
EndPos: yyDollar[3].item.PositionRange().End,
}
}
case 299:
yyDollar = yyS[yypt-6 : yypt+1]
{
yyVAL.node = &DurationExpr{
Op: yyDollar[1].item.Typ,
StartPos: yyDollar[1].item.PositionRange().Start,
EndPos: yyDollar[6].item.PositionRange().End,
LHS: yyDollar[3].node.(Expr),
RHS: yyDollar[5].node.(Expr),
}
}
case 301:
yyDollar = yyS[yypt-3 : yypt+1]
{
yylex.(*parser).experimentalDurationExpr(yyDollar[2].node.(Expr))
if durationExpr, ok := yyDollar[2].node.(*DurationExpr); ok {
durationExpr.Wrapped = true
yyVAL.node = durationExpr
break
}
yyVAL.node = yyDollar[2].node
}
}
goto yystack /* stack new state and value */
}