@ -196,11 +196,12 @@ func (m RangeMapper) Map(expr syntax.SampleExpr, vectorAggrPushdown *syntax.Vect
// Example: expression `count_over_time({app="foo"}[10m])` returns 10m
// Example: expression `count_over_time({app="foo"}[10m])` returns 10m
func getRangeInterval ( expr syntax . SampleExpr ) time . Duration {
func getRangeInterval ( expr syntax . SampleExpr ) time . Duration {
var rangeInterval time . Duration
var rangeInterval time . Duration
expr . Walk ( func ( e syntax . Expr ) {
expr . Walk ( func ( e syntax . Expr ) bool {
switch concrete := e . ( type ) {
switch concrete := e . ( type ) {
case * syntax . RangeAggregationExpr :
case * syntax . RangeAggregationExpr :
rangeInterval = concrete . Left . Interval
rangeInterval = concrete . Left . Interval
}
}
return true
} )
} )
return rangeInterval
return rangeInterval
}
}
@ -209,7 +210,7 @@ func getRangeInterval(expr syntax.SampleExpr) time.Duration {
// such as `| json` or `| logfmt`, that would result in an exploding amount of series in downstream queries.
// such as `| json` or `| logfmt`, that would result in an exploding amount of series in downstream queries.
func hasLabelExtractionStage ( expr syntax . SampleExpr ) bool {
func hasLabelExtractionStage ( expr syntax . SampleExpr ) bool {
found := false
found := false
expr . Walk ( func ( e syntax . Expr ) {
expr . Walk ( func ( e syntax . Expr ) bool {
switch concrete := e . ( type ) {
switch concrete := e . ( type ) {
case * syntax . LogfmtParserExpr :
case * syntax . LogfmtParserExpr :
found = true
found = true
@ -220,6 +221,7 @@ func hasLabelExtractionStage(expr syntax.SampleExpr) bool {
found = true
found = true
}
}
}
}
return true
} )
} )
return found
return found
}
}
@ -297,7 +299,7 @@ func (m RangeMapper) vectorAggrWithRangeDownstreams(expr *syntax.RangeAggregatio
// Returns the updated downstream ConcatSampleExpr.
// Returns the updated downstream ConcatSampleExpr.
func appendDownstream ( downstreams * ConcatSampleExpr , expr syntax . SampleExpr , interval time . Duration , offset time . Duration ) * ConcatSampleExpr {
func appendDownstream ( downstreams * ConcatSampleExpr , expr syntax . SampleExpr , interval time . Duration , offset time . Duration ) * ConcatSampleExpr {
sampleExpr := syntax . MustClone ( expr )
sampleExpr := syntax . MustClone ( expr )
sampleExpr . Walk ( func ( e syntax . Expr ) {
sampleExpr . Walk ( func ( e syntax . Expr ) bool {
switch concrete := e . ( type ) {
switch concrete := e . ( type ) {
case * syntax . RangeAggregationExpr :
case * syntax . RangeAggregationExpr :
concrete . Left . Interval = interval
concrete . Left . Interval = interval
@ -305,6 +307,7 @@ func appendDownstream(downstreams *ConcatSampleExpr, expr syntax.SampleExpr, int
concrete . Left . Offset = offset
concrete . Left . Offset = offset
}
}
}
}
return true
} )
} )
downstreams = & ConcatSampleExpr {
downstreams = & ConcatSampleExpr {
DownstreamSampleExpr : DownstreamSampleExpr {
DownstreamSampleExpr : DownstreamSampleExpr {
@ -319,11 +322,12 @@ func getOffsets(expr syntax.SampleExpr) []time.Duration {
// Expect to always find at most 1 offset, so preallocate it accordingly
// Expect to always find at most 1 offset, so preallocate it accordingly
offsets := make ( [ ] time . Duration , 0 , 1 )
offsets := make ( [ ] time . Duration , 0 , 1 )
expr . Walk ( func ( e syntax . Expr ) {
expr . Walk ( func ( e syntax . Expr ) bool {
switch concrete := e . ( type ) {
switch concrete := e . ( type ) {
case * syntax . RangeAggregationExpr :
case * syntax . RangeAggregationExpr :
offsets = append ( offsets , concrete . Left . Offset )
offsets = append ( offsets , concrete . Left . Offset )
}
}
return true
} )
} )
return offsets
return offsets
}
}