@@ -331,8 +331,8 @@ RETURN %10
331331 })
332332}
333333
334- func TestPlannerCreatesParse (t * testing.T ) {
335- t .Run ("creates Parse instruction for metric query with logfmt " , func (t * testing.T ) {
334+ func TestPlannerCreatesProjectionWithParseOperation (t * testing.T ) {
335+ t .Run ("creates projection instruction with logfmt parse operation for metric query" , func (t * testing.T ) {
336336 // Query with logfmt parser followed by label filter in an instant metric query
337337 q := & query {
338338 statement : `sum by (level) (count_over_time({app="test"} | logfmt | level="error" [5m]))` ,
@@ -353,7 +353,7 @@ func TestPlannerCreatesParse(t *testing.T) {
353353%4 = SELECT %2 [predicate=%3]
354354%5 = LT builtin.timestamp 1970-01-01T02:00:00Z
355355%6 = SELECT %4 [predicate=%5]
356- %7 = PARSE %6 [kind=logfmt ]
356+ %7 = PROJECT %6 [mode=*E, expr=PARSE_LOGFMT(builtin.message) ]
357357%8 = EQ ambiguous.level "error"
358358%9 = SELECT %7 [predicate=%8]
359359%10 = RANGE_AGGREGATION %9 [operation=count, start_ts=1970-01-01T01:00:00Z, end_ts=1970-01-01T02:00:00Z, step=0s, range=5m0s]
@@ -364,7 +364,7 @@ RETURN %12
364364 require .Equal (t , expected , plan .String ())
365365 })
366366
367- t .Run ("creates Parse instruction for log query with logfmt " , func (t * testing.T ) {
367+ t .Run ("creates projection instruction with logfmt parse operation for log query" , func (t * testing.T ) {
368368 q := & query {
369369 statement : `{app="test"} | logfmt | level="error"` ,
370370 start : 3600 ,
@@ -384,7 +384,7 @@ RETURN %12
384384%4 = SELECT %2 [predicate=%3]
385385%5 = LT builtin.timestamp 1970-01-01T02:00:00Z
386386%6 = SELECT %4 [predicate=%5]
387- %7 = PARSE %6 [kind=logfmt ]
387+ %7 = PROJECT %6 [mode=*E, expr=PARSE_LOGFMT(builtin.message) ]
388388%8 = EQ ambiguous.level "error"
389389%9 = SELECT %7 [predicate=%8]
390390%10 = SORT %9 [column=builtin.timestamp, asc=false, nulls_first=false]
@@ -395,7 +395,7 @@ RETURN %12
395395 require .Equal (t , expected , plan .String ())
396396 })
397397
398- t .Run ("creates Parse instruction for metric query with json " , func (t * testing.T ) {
398+ t .Run ("creates projection instruction with json parse operation for metric query" , func (t * testing.T ) {
399399 // Query with logfmt parser followed by label filter in an instant metric query
400400 q := & query {
401401 statement : `sum by (level) (count_over_time({app="test"} | json | level="error" [5m]))` ,
@@ -415,7 +415,7 @@ RETURN %12
415415%4 = SELECT %2 [predicate=%3]
416416%5 = LT builtin.timestamp 1970-01-01T02:00:00Z
417417%6 = SELECT %4 [predicate=%5]
418- %7 = PARSE %6 [kind=json ]
418+ %7 = PROJECT %6 [mode=*E, expr=PARSE_JSON(builtin.message) ]
419419%8 = EQ ambiguous.level "error"
420420%9 = SELECT %7 [predicate=%8]
421421%10 = RANGE_AGGREGATION %9 [operation=count, start_ts=1970-01-01T01:00:00Z, end_ts=1970-01-01T02:00:00Z, step=0s, range=5m0s]
@@ -426,7 +426,7 @@ RETURN %12
426426 require .Equal (t , expected , plan .String ())
427427 })
428428
429- t .Run ("creates Parse instruction for log query with json " , func (t * testing.T ) {
429+ t .Run ("creates projection instruction with json parse operation for log query" , func (t * testing.T ) {
430430 q := & query {
431431 statement : `{app="test"} | json | level="error"` ,
432432 start : 3600 ,
@@ -445,7 +445,7 @@ RETURN %12
445445%4 = SELECT %2 [predicate=%3]
446446%5 = LT builtin.timestamp 1970-01-01T02:00:00Z
447447%6 = SELECT %4 [predicate=%5]
448- %7 = PARSE %6 [kind=json ]
448+ %7 = PROJECT %6 [mode=*E, expr=PARSE_JSON(builtin.message) ]
449449%8 = EQ ambiguous.level "error"
450450%9 = SELECT %7 [predicate=%8]
451451%10 = SORT %9 [column=builtin.timestamp, asc=false, nulls_first=false]
@@ -456,7 +456,7 @@ RETURN %12
456456 require .Equal (t , expected , plan .String ())
457457 })
458458
459- t .Run ("preserves operation order with filters before and after parse" , func (t * testing.T ) {
459+ t .Run ("preserves operation order with filters before and after projection with parse operation " , func (t * testing.T ) {
460460 // Test that filters before logfmt parse are applied before parsing,
461461 // and filters after logfmt parse are applied after parsing.
462462 // This is important for performance - we don't want to parse lines
@@ -484,7 +484,7 @@ RETURN %12
484484%8 = SELECT %6 [predicate=%7]
485485%9 = SELECT %8 [predicate=%2]
486486%10 = SELECT %9 [predicate=%3]
487- %11 = PARSE %10 [kind=logfmt ]
487+ %11 = PROJECT %10 [mode=*E, expr=PARSE_LOGFMT(builtin.message) ]
488488%12 = EQ ambiguous.level "debug"
489489%13 = SELECT %11 [predicate=%12]
490490%14 = SORT %13 [column=builtin.timestamp, asc=false, nulls_first=false]
@@ -496,7 +496,7 @@ RETURN %16
496496 require .Equal (t , expected , plan .String (), "Operations should be in the correct order: LineFilter before Parse, LabelFilter after Parse" )
497497 })
498498
499- t .Run ("preserves operation order in metric query with filters before and after parse" , func (t * testing.T ) {
499+ t .Run ("preserves operation order in metric query with filters before and after projection with parse operation " , func (t * testing.T ) {
500500 // Test that filters before logfmt parse are applied before parsing in metric queries too
501501 q := & query {
502502 statement : `sum by (level) (count_over_time({job="app"} |= "error" | label="value" | logfmt | level="debug" [5m]))` ,
@@ -521,7 +521,7 @@ RETURN %16
521521%8 = SELECT %6 [predicate=%7]
522522%9 = SELECT %8 [predicate=%2]
523523%10 = SELECT %9 [predicate=%3]
524- %11 = PARSE %10 [kind=logfmt ]
524+ %11 = PROJECT %10 [mode=*E, expr=PARSE_LOGFMT(builtin.message) ]
525525%12 = EQ ambiguous.level "debug"
526526%13 = SELECT %11 [predicate=%12]
527527%14 = RANGE_AGGREGATION %13 [operation=count, start_ts=1970-01-01T01:00:00Z, end_ts=1970-01-01T02:00:00Z, step=0s, range=5m0s]
0 commit comments