Skip to content

Commit c6da4b2

Browse files
committed
Add supported query plan version properly
1 parent da99f81 commit c6da4b2

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

pkg/streamingpromql/operators/functions/factories.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -561,11 +561,6 @@ type FunctionMetadata struct {
561561
SplittableOperatorFactory SplittableOperatorFactory
562562
}
563563

564-
type SplittableMetadata struct {
565-
Definition FunctionOverRangeVectorDefinition
566-
OperatorFactor SplittableOperatorFactory
567-
}
568-
569564
func RegisterFunction(function Function, name string, returnType parser.ValueType, factory FunctionOperatorFactory) error {
570565
return RegisterFunctionWithSplitFactory(function, name, returnType, factory, nil)
571566
}

pkg/streamingpromql/operators/functions/split_operator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ func (m *FunctionOverRangeVectorSplit[T]) Finalize(ctx context.Context) error {
468468
"inner_cache_key", m.innerCacheKey,
469469
"query_start_ms", m.queryTimeRange.StartT,
470470
"query_end_ms", m.queryTimeRange.EndT,
471+
"inner_describe", m.innerNode.Describe(),
471472
"splits_total", len(m.splits),
472473
"splits_cached", cachedCount,
473474
"splits_uncached", uncachedCount,

pkg/streamingpromql/optimize/plan/querysplitting/node.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ func (s *SplittableFunctionCall) ExpressionPosition() (posrange.PositionRange, e
129129
}
130130

131131
func (s *SplittableFunctionCall) MinimumRequiredPlanVersion() planning.QueryPlanVersion {
132-
return s.Inner.MinimumRequiredPlanVersion()
132+
// Query splitting with intermediate result caching requires QueryPlanV5
133+
return planning.QueryPlanV5
133134
}
134135

135136
type Materializer struct {

pkg/streamingpromql/optimize/plan/querysplitting/optimization_pass.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ func (o *OptimizationPass) Name() string {
6565
}
6666

6767
func (o *OptimizationPass) Apply(ctx context.Context, plan *planning.QueryPlan, maximumSupportedQueryPlanVersion planning.QueryPlanVersion) (*planning.QueryPlan, error) {
68+
if maximumSupportedQueryPlanVersion < planning.QueryPlanV5 {
69+
return plan, nil
70+
}
71+
6872
var err error
6973
plan.Root, err = o.wrapSplittableRangeVectorFunctions(plan.Root, plan.Parameters.TimeRange)
7074
if err != nil {

pkg/streamingpromql/planning/plan.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func (v QueryPlanVersion) String() string {
2929
return strconv.FormatUint(uint64(v), 10)
3030
}
3131

32-
var MaximumSupportedQueryPlanVersion = QueryPlanV4
32+
var MaximumSupportedQueryPlanVersion = QueryPlanV5
3333

3434
// IMPORTANT:
3535
// Do not change the value or meaning of these constants once they have been merged.
@@ -52,6 +52,9 @@ const QueryPlanV3 = QueryPlanVersion(3)
5252
// QueryPlanV4 introduces support for evaluating smoothed and anchored extended range modifiers.
5353
const QueryPlanV4 = QueryPlanVersion(4)
5454

55+
// QueryPlanV5 introduces support for query splitting with intermediate result caching.
56+
const QueryPlanV5 = QueryPlanVersion(5)
57+
5558
type QueryPlan struct {
5659
Root Node
5760
Parameters *QueryParameters

0 commit comments

Comments
 (0)