From 6b4bf3f69749c6a27a538ce726fc2191703916f0 Mon Sep 17 00:00:00 2001 From: Clayton Peters Date: Fri, 2 Jul 2021 16:52:47 +0100 Subject: [PATCH] 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 --- promql/parser/generated_parser.y | 4 +- promql/parser/generated_parser.y.go | 531 ++++++++++++++-------------- promql/parser/parse_test.go | 4 +- 3 files changed, 274 insertions(+), 265 deletions(-) diff --git a/promql/parser/generated_parser.y b/promql/parser/generated_parser.y index 3f914e4ac..75f147ee4 100644 --- a/promql/parser/generated_parser.y +++ b/promql/parser/generated_parser.y @@ -571,7 +571,7 @@ metric : metric_identifier label_set ; -metric_identifier: AVG | BOTTOMK | BY | COUNT | COUNT_VALUES | GROUP | IDENTIFIER | LAND | LOR | LUNLESS | MAX | METRIC_IDENTIFIER | MIN | OFFSET | QUANTILE | STDDEV | STDVAR | SUM | TOPK | WITHOUT; +metric_identifier: AVG | BOTTOMK | BY | COUNT | COUNT_VALUES | GROUP | IDENTIFIER | LAND | LOR | LUNLESS | MAX | METRIC_IDENTIFIER | MIN | OFFSET | QUANTILE | STDDEV | STDVAR | SUM | TOPK | WITHOUT | START | END; label_set : LEFT_BRACE label_set_list RIGHT_BRACE { $$ = labels.New($2...) } @@ -674,7 +674,7 @@ series_value : IDENTIFIER aggregate_op : AVG | BOTTOMK | COUNT | COUNT_VALUES | GROUP | MAX | MIN | QUANTILE | STDDEV | STDVAR | SUM | TOPK ; // inside of grouping options label names can be recognized as keywords by the lexer. This is a list of keywords that could also be a label name. -maybe_label : AVG | BOOL | BOTTOMK | BY | COUNT | COUNT_VALUES | GROUP | GROUP_LEFT | GROUP_RIGHT | IDENTIFIER | IGNORING | LAND | LOR | LUNLESS | MAX | METRIC_IDENTIFIER | MIN | OFFSET | ON | QUANTILE | STDDEV | STDVAR | SUM | TOPK; +maybe_label : AVG | BOOL | BOTTOMK | BY | COUNT | COUNT_VALUES | GROUP | GROUP_LEFT | GROUP_RIGHT | IDENTIFIER | IGNORING | LAND | LOR | LUNLESS | MAX | METRIC_IDENTIFIER | MIN | OFFSET | ON | QUANTILE | STDDEV | STDVAR | SUM | TOPK | START | END; unary_op : ADD | SUB; diff --git a/promql/parser/generated_parser.y.go b/promql/parser/generated_parser.y.go index e0c5ceac5..5a2aafe3d 100644 --- a/promql/parser/generated_parser.y.go +++ b/promql/parser/generated_parser.y.go @@ -203,252 +203,259 @@ var yyExca = [...]int{ -1, 1, 1, -1, -2, 0, - -1, 33, - 1, 128, - 10, 128, - 22, 128, + -1, 35, + 1, 130, + 10, 130, + 22, 130, -2, 0, - -1, 56, - 2, 140, - 15, 140, - 61, 140, - 67, 140, - -2, 96, - -1, 57, - 2, 141, - 15, 141, - 61, 141, - 67, 141, - -2, 97, -1, 58, 2, 142, 15, 142, 61, 142, 67, 142, - -2, 99, + -2, 96, -1, 59, 2, 143, 15, 143, 61, 143, 67, 143, - -2, 100, + -2, 97, -1, 60, 2, 144, 15, 144, 61, 144, 67, 144, - -2, 101, + -2, 99, -1, 61, 2, 145, 15, 145, 61, 145, 67, 145, - -2, 106, + -2, 100, -1, 62, 2, 146, 15, 146, 61, 146, 67, 146, - -2, 108, + -2, 101, -1, 63, 2, 147, 15, 147, 61, 147, 67, 147, - -2, 110, + -2, 106, -1, 64, 2, 148, 15, 148, 61, 148, 67, 148, - -2, 111, + -2, 108, -1, 65, 2, 149, 15, 149, 61, 149, 67, 149, - -2, 112, + -2, 110, -1, 66, 2, 150, 15, 150, 61, 150, 67, 150, - -2, 113, + -2, 111, -1, 67, 2, 151, 15, 151, 61, 151, 67, 151, + -2, 112, + -1, 68, + 2, 152, + 15, 152, + 61, 152, + 67, 152, + -2, 113, + -1, 69, + 2, 153, + 15, 153, + 61, 153, + 67, 153, -2, 114, - -1, 186, - 12, 193, - 13, 193, - 16, 193, - 17, 193, - 23, 193, - 26, 193, - 32, 193, - 33, 193, - 36, 193, - 42, 193, - 46, 193, - 47, 193, - 48, 193, - 49, 193, - 50, 193, - 51, 193, - 52, 193, - 53, 193, - 54, 193, - 55, 193, - 56, 193, - 57, 193, - 61, 193, - 65, 193, - 67, 193, + -1, 188, + 12, 197, + 13, 197, + 16, 197, + 17, 197, + 23, 197, + 26, 197, + 32, 197, + 33, 197, + 36, 197, + 42, 197, + 46, 197, + 47, 197, + 48, 197, + 49, 197, + 50, 197, + 51, 197, + 52, 197, + 53, 197, + 54, 197, + 55, 197, + 56, 197, + 57, 197, + 61, 197, + 65, 197, + 67, 197, + 70, 197, + 71, 197, -2, 0, - -1, 187, - 12, 193, - 13, 193, - 16, 193, - 17, 193, - 23, 193, - 26, 193, - 32, 193, - 33, 193, - 36, 193, - 42, 193, - 46, 193, - 47, 193, - 48, 193, - 49, 193, - 50, 193, - 51, 193, - 52, 193, - 53, 193, - 54, 193, - 55, 193, - 56, 193, - 57, 193, - 61, 193, - 65, 193, - 67, 193, + -1, 189, + 12, 197, + 13, 197, + 16, 197, + 17, 197, + 23, 197, + 26, 197, + 32, 197, + 33, 197, + 36, 197, + 42, 197, + 46, 197, + 47, 197, + 48, 197, + 49, 197, + 50, 197, + 51, 197, + 52, 197, + 53, 197, + 54, 197, + 55, 197, + 56, 197, + 57, 197, + 61, 197, + 65, 197, + 67, 197, + 70, 197, + 71, 197, -2, 0, - -1, 207, - 19, 191, + -1, 209, + 19, 195, -2, 0, - -1, 254, - 19, 192, + -1, 258, + 19, 196, -2, 0, } const yyPrivate = 57344 -const yyLast = 638 +const yyLast = 654 var yyAct = [...]int{ - 260, 35, 211, 138, 250, 249, 146, 110, 75, 99, - 98, 101, 144, 184, 6, 185, 123, 102, 140, 100, - 186, 187, 55, 145, 245, 141, 150, 149, 263, 244, - 49, 70, 103, 51, 22, 50, 150, 118, 161, 252, - 243, 52, 151, 239, 68, 264, 261, 112, 149, 203, - 18, 19, 151, 105, 20, 106, 238, 111, 139, 104, - 69, 242, 119, 240, 56, 57, 58, 59, 60, 61, - 62, 63, 64, 65, 66, 67, 176, 107, 101, 13, - 147, 148, 158, 24, 102, 30, 2, 3, 4, 5, - 97, 258, 103, 7, 208, 157, 257, 175, 207, 166, - 70, 152, 80, 81, 165, 162, 156, 159, 154, 256, - 155, 206, 31, 90, 91, 164, 141, 93, 94, 96, - 117, 183, 116, 174, 265, 182, 188, 189, 190, 191, + 264, 37, 213, 140, 254, 253, 148, 112, 77, 101, + 100, 146, 186, 103, 187, 188, 189, 6, 102, 104, + 125, 267, 248, 147, 57, 99, 151, 247, 120, 51, + 72, 105, 53, 22, 52, 152, 72, 163, 265, 256, + 54, 268, 249, 70, 152, 243, 151, 205, 246, 18, + 19, 153, 95, 20, 98, 107, 105, 108, 242, 71, + 153, 106, 121, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 178, 97, 103, 13, 149, + 150, 109, 24, 104, 30, 33, 142, 31, 32, 2, + 3, 4, 5, 143, 210, 262, 177, 7, 209, 143, + 261, 168, 269, 154, 114, 79, 167, 164, 158, 161, + 156, 208, 157, 260, 113, 78, 48, 166, 81, 34, + 244, 175, 73, 185, 1, 176, 141, 184, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, - 79, 95, 181, 202, 124, 125, 126, 127, 128, 129, - 130, 131, 132, 133, 134, 135, 136, 137, 255, 10, - 168, 77, 169, 153, 54, 141, 112, 9, 9, 72, - 141, 76, 32, 241, 204, 205, 111, 173, 34, 97, - 49, 70, 109, 51, 22, 50, 246, 171, 1, 247, - 248, 52, 81, 251, 68, 8, 253, 170, 172, 33, - 18, 19, 90, 91, 20, 97, 93, 46, 96, 45, - 69, 254, 44, 71, 56, 57, 58, 59, 60, 61, - 62, 63, 64, 65, 66, 67, 43, 77, 42, 13, - 95, 122, 93, 24, 96, 30, 41, 76, 40, 39, - 120, 259, 178, 74, 160, 38, 262, 49, 70, 180, - 51, 22, 50, 121, 149, 37, 95, 115, 52, 36, - 267, 68, 114, 150, 268, 47, 142, 18, 19, 179, - 78, 20, 177, 113, 209, 73, 143, 69, 53, 151, - 212, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 213, 167, 48, 13, 108, 0, 0, - 24, 0, 30, 223, 0, 0, 0, 229, 0, 0, - 0, 266, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 225, 226, 0, 0, 227, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 214, 216, 218, - 219, 220, 228, 230, 233, 234, 235, 236, 237, 213, - 0, 215, 217, 221, 222, 224, 231, 232, 0, 223, - 0, 0, 0, 229, 0, 0, 0, 210, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 225, - 226, 0, 0, 227, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 214, 216, 218, 219, 220, 228, 230, - 233, 234, 235, 236, 237, 0, 0, 215, 217, 221, - 222, 224, 231, 232, 17, 70, 0, 0, 22, 0, + 202, 203, 257, 47, 183, 204, 126, 127, 128, 129, + 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, + 160, 46, 170, 117, 171, 259, 8, 119, 116, 118, + 35, 155, 143, 159, 114, 245, 206, 207, 143, 115, + 36, 99, 51, 72, 113, 53, 22, 52, 250, 173, + 111, 251, 252, 54, 83, 255, 70, 10, 45, 172, + 174, 44, 18, 19, 92, 93, 20, 74, 95, 124, + 98, 56, 71, 258, 9, 9, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 215, 43, + 42, 13, 97, 79, 41, 24, 122, 30, 225, 162, + 31, 32, 231, 78, 40, 263, 270, 123, 180, 76, + 266, 39, 38, 49, 144, 182, 181, 80, 227, 228, + 151, 179, 229, 211, 271, 75, 145, 55, 272, 152, + 214, 169, 216, 218, 220, 221, 222, 230, 232, 235, + 236, 237, 238, 239, 50, 153, 217, 219, 223, 224, + 226, 233, 234, 110, 0, 0, 240, 241, 51, 72, + 0, 53, 22, 52, 0, 0, 0, 0, 0, 54, + 0, 0, 70, 0, 0, 0, 0, 0, 18, 19, + 0, 0, 20, 0, 0, 0, 0, 0, 71, 0, + 0, 0, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 215, 0, 0, 13, 0, 0, + 0, 24, 0, 30, 225, 0, 31, 32, 231, 0, + 0, 0, 212, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 227, 228, 0, 0, 229, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 216, 218, + 220, 221, 222, 230, 232, 235, 236, 237, 238, 239, + 0, 0, 217, 219, 223, 224, 226, 233, 234, 0, + 17, 72, 240, 241, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 18, 19, 0, 0, 20, 0, - 17, 31, 0, 0, 22, 0, 0, 0, 11, 12, - 14, 15, 16, 21, 23, 25, 26, 27, 28, 29, - 18, 19, 0, 13, 20, 0, 0, 24, 0, 30, - 0, 0, 0, 0, 11, 12, 14, 15, 16, 21, - 23, 25, 26, 27, 28, 29, 97, 0, 0, 13, - 0, 0, 163, 24, 0, 30, 0, 0, 80, 81, - 82, 0, 83, 84, 85, 86, 87, 88, 89, 90, - 91, 92, 0, 93, 94, 96, 0, 0, 0, 0, - 0, 0, 97, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 80, 81, 82, 95, 83, 84, - 85, 86, 87, 88, 89, 90, 91, 92, 0, 93, - 94, 96, 0, 0, 97, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 80, 81, 82, 0, - 83, 84, 85, 95, 87, 88, 89, 90, 91, 92, - 0, 93, 94, 96, 0, 0, 97, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 80, 81, - 82, 0, 83, 84, 0, 95, 87, 88, 0, 90, - 91, 92, 0, 93, 94, 96, 0, 0, 0, 0, + 18, 19, 0, 0, 20, 0, 17, 33, 0, 0, + 22, 0, 0, 0, 11, 12, 14, 15, 16, 21, + 23, 25, 26, 27, 28, 29, 18, 19, 0, 13, + 20, 0, 0, 24, 0, 30, 0, 0, 31, 32, + 11, 12, 14, 15, 16, 21, 23, 25, 26, 27, + 28, 29, 0, 0, 99, 13, 0, 0, 0, 24, + 165, 30, 0, 0, 31, 32, 82, 83, 84, 0, + 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, + 0, 95, 96, 98, 0, 0, 0, 0, 0, 0, + 99, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 82, 83, 84, 97, 85, 86, 87, 88, + 89, 90, 91, 92, 93, 94, 0, 95, 96, 98, + 0, 0, 99, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 82, 83, 84, 0, 85, 86, + 87, 97, 89, 90, 91, 92, 93, 94, 0, 95, + 96, 98, 0, 0, 99, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 82, 83, 84, 0, + 85, 86, 99, 97, 89, 90, 0, 92, 93, 94, + 0, 95, 96, 98, 82, 83, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 92, 93, 0, 0, 95, + 96, 98, 0, 0, 0, 97, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 95, + 0, 0, 0, 97, } var yyPact = [...]int{ - 12, 83, 428, 428, 168, 402, -1000, -1000, -1000, 99, + 15, 87, 424, 424, 170, 398, -1000, -1000, -1000, 72, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, 225, -1000, 138, -1000, 508, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 17, 77, - -1000, 235, -1000, 235, 87, -1000, -1000, -1000, -1000, -1000, + -1000, -1000, -1000, 231, -1000, 116, -1000, 506, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - 164, -1000, -1000, 255, -1000, -1000, 118, -1000, 15, -1000, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, 16, 10, 161, 77, -50, - -1000, 80, 80, 18, -1000, 472, 191, -1000, 97, -1000, - -1000, 158, -1000, -1000, 159, -1000, 74, -1000, 237, 235, - -1000, -51, -42, -1000, 235, 235, 235, 235, 235, 235, - 235, 235, 235, 235, 235, 235, 235, 235, -1000, 107, - -1000, -1000, -1000, 34, -1000, -1000, -1000, -1000, -1000, -1000, - 31, 31, 92, -1000, -1000, -1000, -1000, 347, -1000, -1000, - 36, -1000, 508, -1000, -1000, 45, -1000, 38, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 5, 0, - -1000, -1000, -1000, 165, 80, 80, 80, 80, 191, 76, - 76, 76, 572, 540, 76, 76, 572, 191, 191, 76, - 191, 165, -1000, 19, -1000, -1000, -1000, 156, -1000, 89, + 16, 41, -1000, 286, -1000, 286, 23, -1000, -1000, -1000, + -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, + -1000, -1000, 172, -1000, -1000, 161, -1000, -1000, 165, -1000, + 6, -1000, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, 84, 9, 169, + 41, -48, -1000, 158, 158, 17, -1000, 470, 11, -1000, + 99, -1000, -1000, 160, -1000, -1000, 103, -1000, 73, -1000, + 243, 286, -1000, -52, -47, -1000, 286, 286, 286, 286, + 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, + -1000, 90, -1000, -1000, -1000, 32, -1000, -1000, -1000, -1000, + -1000, -1000, 29, 29, 92, -1000, -1000, -1000, -1000, 342, + -1000, -1000, 38, -1000, 506, -1000, -1000, 102, -1000, 25, + -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, + -2, 18, -1000, -1000, -1000, 167, 158, 158, 158, 158, + 11, 588, 588, 588, 570, 538, 588, 588, 570, 11, + 11, 588, 11, 167, -1000, 19, -1000, -1000, -1000, 163, + -1000, 93, -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, -1000, -1000, -1000, -1000, -1000, 235, - -1000, -1000, -1000, -1000, 29, 29, 4, -1000, -1000, -1000, - -1000, -1000, -1000, 26, 122, -1000, -1000, 291, -1000, 508, - -1000, -1000, -1000, 29, -1000, -1000, -1000, -1000, -1000, + -1000, -1000, -1000, 286, -1000, -1000, -1000, -1000, 21, 21, + -3, -1000, -1000, -1000, -1000, -1000, -1000, 22, 100, -1000, + -1000, 226, -1000, 506, -1000, -1000, -1000, 21, -1000, -1000, + -1000, -1000, -1000, } var yyPgo = [...]int{ - 0, 297, 7, 295, 2, 294, 280, 164, 278, 276, - 159, 275, 195, 8, 274, 4, 5, 272, 270, 0, - 23, 269, 6, 266, 265, 259, 10, 62, 255, 253, - 1, 245, 244, 9, 240, 22, 239, 238, 236, 231, - 228, 226, 212, 209, 207, 3, 196, 188, 172, + 0, 293, 7, 284, 2, 271, 270, 211, 267, 266, + 197, 265, 166, 8, 263, 4, 5, 261, 257, 0, + 23, 256, 6, 254, 253, 252, 10, 62, 251, 247, + 1, 244, 239, 9, 236, 24, 234, 230, 229, 209, + 201, 198, 161, 143, 116, 3, 142, 124, 119, } var yyR1 = [...]int{ @@ -463,15 +470,15 @@ var yyR1 = [...]int{ 43, 44, 44, 44, 35, 35, 35, 1, 1, 1, 2, 2, 2, 2, 12, 12, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, - 11, 11, 11, 13, 13, 13, 13, 48, 18, 18, - 18, 18, 17, 17, 17, 17, 17, 21, 21, 21, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 6, 6, 6, 6, 6, 6, 6, 6, + 7, 7, 7, 7, 7, 7, 7, 7, 10, 10, + 10, 10, 11, 11, 11, 13, 13, 13, 13, 48, + 18, 18, 18, 18, 17, 17, 17, 17, 17, 21, + 21, 21, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 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, 37, 20, 22, 22, 23, 23, 19, 45, - 41, 46, 46, 16, 16, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 8, 8, 5, 5, 5, 5, 37, 20, 22, 22, + 23, 23, 19, 45, 41, 46, 46, 16, 16, } var yyR2 = [...]int{ @@ -486,75 +493,77 @@ var yyR2 = [...]int{ 2, 2, 1, 1, 3, 4, 2, 3, 1, 2, 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, 3, 4, 2, 0, - 3, 1, 2, 3, 3, 2, 1, 2, 0, 3, - 2, 1, 1, 3, 1, 3, 4, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 3, 4, + 2, 0, 3, 1, 2, 3, 3, 2, 1, 2, + 0, 3, 2, 1, 1, 3, 1, 3, 4, 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, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, - 1, 0, 1, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, + 1, 1, 1, 1, 1, 0, 1, 0, 1, } var yyChk = [...]int{ -1000, -47, 74, 75, 76, 77, 2, 10, -12, -7, -10, 46, 47, 61, 48, 49, 50, 12, 32, 33, 36, 51, 16, 52, 65, 53, 54, 55, 56, 57, - 67, 13, -48, -12, 10, -30, -25, -28, -31, -36, - -37, -38, -40, -41, -42, -43, -44, -24, -3, 12, - 17, 15, 23, -8, -7, -35, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 26, 42, - 13, -44, -10, -11, 18, -13, 12, 2, -18, 2, - 26, 27, 28, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 41, 42, 65, 43, 14, -26, -33, - 2, 61, 67, 15, -33, -30, -30, -35, -1, 18, - -2, 12, 2, 18, 7, 2, 4, 2, 22, -27, - -34, -29, -39, 60, -27, -27, -27, -27, -27, -27, - -27, -27, -27, -27, -27, -27, -27, -27, -45, 42, - 2, 9, -23, -9, 2, -20, -22, 70, 71, 17, - 26, 42, -45, 2, -33, -26, -15, 15, 2, -15, - -32, 20, -30, 20, 18, 7, 2, -5, 2, 4, - 39, 29, 40, 18, -13, 23, 2, -17, 5, -21, - 12, -20, -22, -30, 64, 66, 62, 63, -30, -30, + 67, 70, 71, 13, -48, -12, 10, -30, -25, -28, + -31, -36, -37, -38, -40, -41, -42, -43, -44, -24, + -3, 12, 17, 15, 23, -8, -7, -35, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 26, 42, 13, -44, -10, -11, 18, -13, 12, 2, + -18, 2, 26, 27, 28, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 41, 42, 65, 43, 14, + -26, -33, 2, 61, 67, 15, -33, -30, -30, -35, + -1, 18, -2, 12, 2, 18, 7, 2, 4, 2, + 22, -27, -34, -29, -39, 60, -27, -27, -27, -27, + -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, + -45, 42, 2, 9, -23, -9, 2, -20, -22, 70, + 71, 17, 26, 42, -45, 2, -33, -26, -15, 15, + 2, -15, -32, 20, -30, 20, 18, 7, 2, -5, + 2, 4, 39, 29, 40, 18, -13, 23, 2, -17, + 5, -21, 12, -20, -22, -30, 64, 66, 62, 63, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -45, 15, -20, -20, 19, 6, 2, -14, - 20, -4, -6, 2, 46, 60, 47, 61, 48, 49, - 50, 62, 63, 12, 64, 32, 33, 36, 51, 16, - 52, 65, 66, 53, 54, 55, 56, 57, 20, 7, - 18, -2, 23, 2, 24, 24, -22, -15, -15, -16, - -15, -16, 20, -46, -45, 2, 20, 7, 2, -30, - -19, 17, -19, 24, 19, 2, 20, -4, -19, + -30, -30, -30, -30, -45, 15, -20, -20, 19, 6, + 2, -14, 20, -4, -6, 2, 46, 60, 47, 61, + 48, 49, 50, 62, 63, 12, 64, 32, 33, 36, + 51, 16, 52, 65, 66, 53, 54, 55, 56, 57, + 70, 71, 20, 7, 18, -2, 23, 2, 24, 24, + -22, -15, -15, -16, -15, -16, 20, -46, -45, 2, + 20, 7, 2, -30, -19, 17, -19, 24, 19, 2, + 20, -4, -19, } var yyDef = [...]int{ - 0, -2, 119, 119, 0, 0, 7, 6, 1, 119, + 0, -2, 121, 121, 0, 0, 7, 6, 1, 121, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, - 115, 0, 2, -2, 3, 4, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 0, 102, - 182, 0, 190, 0, 82, 83, -2, -2, -2, -2, - -2, -2, -2, -2, -2, -2, -2, -2, 176, 177, - 0, 5, 94, 0, 118, 121, 0, 126, 127, 131, - 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 0, 0, 0, 0, 22, - 23, 0, 0, 0, 59, 0, 80, 81, 0, 86, - 88, 0, 93, 116, 0, 122, 0, 125, 130, 0, - 41, 46, 47, 43, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 66, 0, - 68, 189, 69, 0, 71, 186, 187, 72, 73, 183, - 0, 0, 0, 79, 20, 21, 24, 0, 53, 25, - 0, 61, 63, 65, 84, 0, 89, 0, 92, 178, - 179, 180, 181, 117, 120, 123, 124, 129, 132, 134, - 137, 138, 139, 26, 0, 0, -2, -2, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 67, 0, 184, 185, 74, -2, 78, 0, - 52, 55, 57, 58, 152, 153, 154, 155, 156, 157, + 115, 116, 117, 0, 2, -2, 3, 4, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 0, 102, 186, 0, 194, 0, 82, 83, -2, -2, + -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, + 180, 181, 0, 5, 94, 0, 120, 123, 0, 128, + 129, 133, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 0, 0, 0, + 0, 22, 23, 0, 0, 0, 59, 0, 80, 81, + 0, 86, 88, 0, 93, 118, 0, 124, 0, 127, + 132, 0, 41, 46, 47, 43, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 66, 0, 68, 193, 69, 0, 71, 190, 191, 72, + 73, 187, 0, 0, 0, 79, 20, 21, 24, 0, + 53, 25, 0, 61, 63, 65, 84, 0, 89, 0, + 92, 182, 183, 184, 185, 119, 122, 125, 126, 131, + 134, 136, 139, 140, 141, 26, 0, 0, -2, -2, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 67, 0, 188, 189, 74, -2, + 78, 0, 52, 55, 57, 58, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, - 168, 169, 170, 171, 172, 173, 174, 175, 60, 64, - 85, 87, 90, 91, 0, 0, 0, 44, 45, 48, - 194, 49, 70, 0, -2, 77, 50, 0, 56, 62, - 133, 188, 135, 0, 75, 76, 51, 54, 136, + 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, + 178, 179, 60, 64, 85, 87, 90, 91, 0, 0, + 0, 44, 45, 48, 198, 49, 70, 0, -2, 77, + 50, 0, 56, 62, 135, 192, 137, 0, 75, 76, + 51, 54, 138, } var yyTok1 = [...]int{ @@ -1478,77 +1487,77 @@ yydefault: { yyVAL.labels = yyDollar[1].labels } - case 116: + case 118: yyDollar = yyS[yypt-3 : yypt+1] //line generated_parser.y:577 { yyVAL.labels = labels.New(yyDollar[2].labels...) } - case 117: + case 119: yyDollar = yyS[yypt-4 : yypt+1] //line generated_parser.y:579 { yyVAL.labels = labels.New(yyDollar[2].labels...) } - case 118: + case 120: yyDollar = yyS[yypt-2 : yypt+1] //line generated_parser.y:581 { yyVAL.labels = labels.New() } - case 119: + case 121: yyDollar = yyS[yypt-0 : yypt+1] //line generated_parser.y:583 { yyVAL.labels = labels.New() } - case 120: + case 122: yyDollar = yyS[yypt-3 : yypt+1] //line generated_parser.y:587 { yyVAL.labels = append(yyDollar[1].labels, yyDollar[3].label) } - case 121: + case 123: yyDollar = yyS[yypt-1 : yypt+1] //line generated_parser.y:589 { yyVAL.labels = []labels.Label{yyDollar[1].label} } - case 122: + case 124: yyDollar = yyS[yypt-2 : yypt+1] //line generated_parser.y:591 { yylex.(*parser).unexpected("label set", "\",\" or \"}\"") yyVAL.labels = yyDollar[1].labels } - case 123: + case 125: yyDollar = yyS[yypt-3 : yypt+1] //line generated_parser.y:596 { yyVAL.label = labels.Label{Name: yyDollar[1].item.Val, Value: yylex.(*parser).unquoteString(yyDollar[3].item.Val)} } - case 124: + case 126: yyDollar = yyS[yypt-3 : yypt+1] //line generated_parser.y:598 { yylex.(*parser).unexpected("label set", "string") yyVAL.label = labels.Label{} } - case 125: + case 127: yyDollar = yyS[yypt-2 : yypt+1] //line generated_parser.y:600 { yylex.(*parser).unexpected("label set", "\"=\"") yyVAL.label = labels.Label{} } - case 126: + case 128: yyDollar = yyS[yypt-1 : yypt+1] //line generated_parser.y:602 { yylex.(*parser).unexpected("label set", "identifier or \"}\"") yyVAL.label = labels.Label{} } - case 127: + case 129: yyDollar = yyS[yypt-2 : yypt+1] //line generated_parser.y:610 { @@ -1557,38 +1566,38 @@ yydefault: values: yyDollar[2].series, } } - case 128: + case 130: yyDollar = yyS[yypt-0 : yypt+1] //line generated_parser.y:619 { yyVAL.series = []SequenceValue{} } - case 129: + case 131: yyDollar = yyS[yypt-3 : yypt+1] //line generated_parser.y:621 { yyVAL.series = append(yyDollar[1].series, yyDollar[3].series...) } - case 130: + case 132: yyDollar = yyS[yypt-2 : yypt+1] //line generated_parser.y:623 { yyVAL.series = yyDollar[1].series } - case 131: + case 133: yyDollar = yyS[yypt-1 : yypt+1] //line generated_parser.y:625 { yylex.(*parser).unexpected("series values", "") yyVAL.series = nil } - case 132: + case 134: yyDollar = yyS[yypt-1 : yypt+1] //line generated_parser.y:629 { yyVAL.series = []SequenceValue{{Omitted: true}} } - case 133: + case 135: yyDollar = yyS[yypt-3 : yypt+1] //line generated_parser.y:631 { @@ -1597,13 +1606,13 @@ yydefault: yyVAL.series = append(yyVAL.series, SequenceValue{Omitted: true}) } } - case 134: + case 136: yyDollar = yyS[yypt-1 : yypt+1] //line generated_parser.y:638 { yyVAL.series = []SequenceValue{{Value: yyDollar[1].float}} } - case 135: + case 137: yyDollar = yyS[yypt-3 : yypt+1] //line generated_parser.y:640 { @@ -1612,7 +1621,7 @@ yydefault: yyVAL.series = append(yyVAL.series, SequenceValue{Value: yyDollar[1].float}) } } - case 136: + case 138: yyDollar = yyS[yypt-4 : yypt+1] //line generated_parser.y:647 { @@ -1622,7 +1631,7 @@ yydefault: yyDollar[1].float += yyDollar[2].float } } - case 137: + case 139: yyDollar = yyS[yypt-1 : yypt+1] //line generated_parser.y:657 { @@ -1631,7 +1640,7 @@ yydefault: } yyVAL.float = math.Float64frombits(value.StaleNaN) } - case 182: + case 186: yyDollar = yyS[yypt-1 : yypt+1] //line generated_parser.y:688 { @@ -1640,25 +1649,25 @@ yydefault: PosRange: yyDollar[1].item.PositionRange(), } } - case 183: + case 187: yyDollar = yyS[yypt-1 : yypt+1] //line generated_parser.y:696 { yyVAL.float = yylex.(*parser).number(yyDollar[1].item.Val) } - case 184: + case 188: yyDollar = yyS[yypt-2 : yypt+1] //line generated_parser.y:698 { yyVAL.float = yyDollar[2].float } - case 185: + case 189: yyDollar = yyS[yypt-2 : yypt+1] //line generated_parser.y:699 { yyVAL.float = -yyDollar[2].float } - case 188: + case 192: yyDollar = yyS[yypt-1 : yypt+1] //line generated_parser.y:705 { @@ -1668,7 +1677,7 @@ yydefault: yylex.(*parser).addParseErrf(yyDollar[1].item.PositionRange(), "invalid repetition in series values: %s", err) } } - case 189: + case 193: yyDollar = yyS[yypt-1 : yypt+1] //line generated_parser.y:715 { @@ -1678,7 +1687,7 @@ yydefault: yylex.(*parser).addParseErr(yyDollar[1].item.PositionRange(), err) } } - case 190: + case 194: yyDollar = yyS[yypt-1 : yypt+1] //line generated_parser.y:726 { @@ -1687,13 +1696,13 @@ yydefault: PosRange: yyDollar[1].item.PositionRange(), } } - case 191: + case 195: yyDollar = yyS[yypt-0 : yypt+1] //line generated_parser.y:739 { yyVAL.duration = 0 } - case 193: + case 197: yyDollar = yyS[yypt-0 : yypt+1] //line generated_parser.y:743 { diff --git a/promql/parser/parse_test.go b/promql/parser/parse_test.go index 9b3a8c84b..a2f996791 100644 --- a/promql/parser/parse_test.go +++ b/promql/parser/parse_test.go @@ -3172,11 +3172,11 @@ var testExpr = []struct { }, { input: `start()`, fail: true, - errMsg: `1:1: parse error: unexpected "start"`, + errMsg: `1:6: parse error: unexpected "("`, }, { input: `end()`, fail: true, - errMsg: `1:1: parse error: unexpected "end"`, + errMsg: `1:4: parse error: unexpected "("`, }, }