@@ -118,23 +118,24 @@ public LogicalPlan visitSelector(PromqlBaseParser.SelectorContext ctx) {
118118 throw new ParsingException (source (labelsCtx ), "Vector selector must contain at least one non-empty matcher" );
119119 }
120120 }
121+ final LabelMatchers matchers = new LabelMatchers (labels );
122+ UnresolvedAttribute timestamp = new UnresolvedAttribute (source , MetadataAttribute .TIMESTAMP_FIELD );
123+
121124 Evaluation evaluation = visitEvaluation (ctx .evaluation ());
122- TimeValue range = visitDuration (ctx .duration ());
123- // TODO: TimeValue might not be needed after all
124- Expression rangeEx = new Literal (source (ctx .duration ()), Duration .ofSeconds (range .getSeconds ()), DataType .TIME_DURATION );
125125 // fall back to default
126126 if (evaluation == null ) {
127127 evaluation = new Evaluation (start );
128128 }
129-
130- final LabelMatchers matchers = new LabelMatchers (labels );
131129 final Evaluation finalEvaluation = evaluation ;
130+ PromqlBaseParser .DurationContext duration = ctx .duration ();
131+ if (duration == null ) {
132+ return new InstantSelector (source , series , labelExpressions , matchers , finalEvaluation , timestamp );
133+ }
134+ TimeValue range = visitDuration (duration );
135+ // TODO: TimeValue might not be needed after all
136+ Expression rangeEx = new Literal (source (duration ), Duration .ofSeconds (range .getSeconds ()), DataType .TIME_DURATION );
132137
133- UnresolvedAttribute timestamp = new UnresolvedAttribute (source , MetadataAttribute .TIMESTAMP_FIELD );
134-
135- return range == null
136- ? new InstantSelector (source , series , labelExpressions , matchers , finalEvaluation , timestamp )
137- : new RangeSelector (source , series , labelExpressions , matchers , rangeEx , finalEvaluation , timestamp );
138+ return new RangeSelector (source , series , labelExpressions , matchers , rangeEx , finalEvaluation , timestamp );
138139 }
139140
140141 @ Override
0 commit comments