@@ -108,10 +108,9 @@ func TestConvertAST_Success(t *testing.T) {
108108%16 = SELECT %14 [predicate=%15]
109109%17 = SELECT %16 [predicate=%6]
110110%18 = SELECT %17 [predicate=%11]
111- %19 = SORT %18 [column=builtin.timestamp, asc=false, nulls_first=false]
112- %20 = LIMIT %19 [skip=0, fetch=1000]
113- %21 = LOGQL_COMPAT %20
114- RETURN %21
111+ %19 = TOPK %18 [sort_by=builtin.timestamp, k=1000, asc=false, nulls_first=false]
112+ %20 = LOGQL_COMPAT %19
113+ RETURN %20
115114`
116115
117116 require .Equal (t , expected , logicalPlan .String ())
@@ -471,10 +470,9 @@ RETURN %12
471470%7 = PROJECT %6 [mode=*E, expr=PARSE_LOGFMT(builtin.message, [], false, false)]
472471%8 = EQ ambiguous.level "error"
473472%9 = SELECT %7 [predicate=%8]
474- %10 = SORT %9 [column=builtin.timestamp, asc=false, nulls_first=false]
475- %11 = LIMIT %10 [skip=0, fetch=1000]
476- %12 = LOGQL_COMPAT %11
477- RETURN %12
473+ %10 = TOPK %9 [sort_by=builtin.timestamp, k=1000, asc=false, nulls_first=false]
474+ %11 = LOGQL_COMPAT %10
475+ RETURN %11
478476`
479477 require .Equal (t , expected , plan .String ())
480478 })
@@ -532,10 +530,9 @@ RETURN %12
532530%7 = PROJECT %6 [mode=*E, expr=PARSE_JSON(builtin.message, [], false, false)]
533531%8 = EQ ambiguous.level "error"
534532%9 = SELECT %7 [predicate=%8]
535- %10 = SORT %9 [column=builtin.timestamp, asc=false, nulls_first=false]
536- %11 = LIMIT %10 [skip=0, fetch=1000]
537- %12 = LOGQL_COMPAT %11
538- RETURN %12
533+ %10 = TOPK %9 [sort_by=builtin.timestamp, k=1000, asc=false, nulls_first=false]
534+ %11 = LOGQL_COMPAT %10
535+ RETURN %11
539536`
540537 require .Equal (t , expected , plan .String ())
541538 })
@@ -571,10 +568,9 @@ RETURN %12
571568%11 = PROJECT %10 [mode=*E, expr=PARSE_LOGFMT(builtin.message, [], false, false)]
572569%12 = EQ ambiguous.level "debug"
573570%13 = SELECT %11 [predicate=%12]
574- %14 = SORT %13 [column=builtin.timestamp, asc=false, nulls_first=false]
575- %15 = LIMIT %14 [skip=0, fetch=1000]
576- %16 = LOGQL_COMPAT %15
577- RETURN %16
571+ %14 = TOPK %13 [sort_by=builtin.timestamp, k=1000, asc=false, nulls_first=false]
572+ %15 = LOGQL_COMPAT %14
573+ RETURN %15
578574`
579575
580576 require .Equal (t , expected , plan .String (), "Operations should be in the correct order: LineFilter before Parse, LabelFilter after Parse" )
@@ -642,10 +638,9 @@ func TestPlannerCreatesProjection(t *testing.T) {
642638%5 = LT builtin.timestamp 1970-01-01T01:00:00Z
643639%6 = SELECT %4 [predicate=%5]
644640%7 = PROJECT %6 [mode=*D, expr=ambiguous.level, expr=ambiguous.detected_level]
645- %8 = SORT %7 [column=builtin.timestamp, asc=false, nulls_first=false]
646- %9 = LIMIT %8 [skip=0, fetch=0]
647- %10 = LOGQL_COMPAT %9
648- RETURN %10
641+ %8 = TOPK %7 [sort_by=builtin.timestamp, k=0, asc=false, nulls_first=false]
642+ %9 = LOGQL_COMPAT %8
643+ RETURN %9
649644`
650645 require .Equal (t , expected , plan .String ())
651646 })
0 commit comments