Skip to content

Conversation

charleskorn
Copy link
Contributor

What this PR does

This PR introduces a ResultType method for the query planner Node interface.

This will allow optimization passes to correctly handle nodes that produce different kinds of values.

I'm raising this as a separate PR in the interests of keeping the upcoming common subexpression elimination PR smaller.

Which issue(s) this PR fixes or relates to

(none)

Checklist

  • [n/a] Tests updated.
  • [n/a] Documentation added.
  • [covered by Mimir Query Engine #10067] CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • [n/a] about-versioning.md updated with experimental features.

@charleskorn charleskorn marked this pull request as ready for review April 7, 2025 06:16
@charleskorn charleskorn requested a review from a team as a code owner April 7, 2025 06:16
@@ -128,3 +129,15 @@ func (f *FunctionCall) OperatorFactory(children []types.Operator, timeRange type
return nil, compat.NewNotSupportedError(fmt.Sprintf("'%v' function", f.FunctionName))
}
}

func (f *FunctionCall) ResultType() (parser.ValueType, error) {
if _, ok := functions.InstantVectorFunctionOperatorFactories[f.FunctionName]; ok || f.FunctionName == "absent" || f.FunctionName == "absent_over_time" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit of a nit, but I dislike we have to keep this special case in multiple places.

We should add a comment at least.

But I wonder if we can make this better. Maybe some kind of dummy entry in functions.InstantVectorFunctionOperatorFactories ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I worry that a dummy entry in functions.InstantVectorFunctionOperatorFactories might cause other problems or confusion.

I'm not expecting to need further instances of this special case anywhere else, if that helps allay your concerns.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if it panics when used incorrectly it could work, but I'm nit picking so I'm okay with it as is, but would love a comment on the line please.

@charleskorn charleskorn enabled auto-merge (squash) April 8, 2025 04:21
@charleskorn charleskorn merged commit 1f92d7a into main Apr 8, 2025
26 checks passed
@charleskorn charleskorn deleted the charleskorn/mqe-query-planner-node-result-type branch April 8, 2025 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants